// private void DeregisterCaps(UUID agentID, Caps caps) // { // string capUrl; // // if (m_capsDict.TryGetValue(agentID, out capUrl)) // { // MainServer.Instance.RemoveHTTPHandler("", capUrl); // m_capsDict.Remove(agentID); // } // } private static void DoInventoryRequests() { APollRequest poolreq; while (true) { if (!m_queue.TryTake(out poolreq, 4500) || poolreq == null || poolreq.thepoll == null) { Watchdog.UpdateThread(); continue; } Watchdog.UpdateThread(); try { APollRequest req = poolreq; req.thepoll.Process(req); } catch (Exception e) { m_log.ErrorFormat( "[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {2}", poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e); } } }
public void Process(APollRequest requestinfo) { Hashtable curresponse; UUID requestID = requestinfo.reqID; if (m_scene.ShuttingDown) { return; } lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } // If the avatar is gone, don't bother to get the texture if (m_scene.GetScenePresence(Id) == null) { curresponse = new Hashtable(); curresponse["int_response_code"] = 500; curresponse["str_response_string"] = "Script timeout"; curresponse["content_type"] = "text/plain"; curresponse["keepalive"] = false; responses[requestID] = new APollResponse() { bytes = 0, response = curresponse }; return; } } curresponse = m_getMeshHandler.Handle(requestinfo.request); lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } responses[requestID] = new APollResponse() { bytes = (int)curresponse["int_bytes"], response = curresponse }; } }
public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : base(null, url, null, null, null, null, pId, int.MaxValue) { m_module = module; HasEvents = (requestID, y) => { lock (responses) return(responses.ContainsKey(requestID)); }; Drop = (requestID, y) => { lock (responses) { responses.Remove(requestID); lock (dropedResponses) dropedResponses.Add(requestID); } }; GetEvents = (requestID, y) => { lock (responses) { try { return(responses[requestID]); } finally { responses.Remove(requestID); } } }; Request = (requestID, request) => { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = requestID; reqinfo.request = request; m_workerpool.Enqueue(reqinfo); return(null); }; NoEvents = (x, y) => { Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; return(response); }; }
public void Process(APollRequest requestinfo) { if (m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown) { return; } UUID requestID = requestinfo.reqID; lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } } Hashtable response = new Hashtable(); response["int_response_code"] = 200; response["content_type"] = "text/plain"; // response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( // requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); response["bin_response_data"] = System.Text.Encoding.UTF8.GetBytes( m_webFetchHandler.FetchInventoryDescendentsRequest( requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null) ); lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); requestinfo.request.Clear(); WebFetchInvDescModule.ProcessedRequestsCount++; return; } } if (responses.ContainsKey(requestID)) { m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); } responses[requestID] = response; } requestinfo.request.Clear(); WebFetchInvDescModule.ProcessedRequestsCount++; }
public void Process(APollRequest requestinfo) { UUID requestID = requestinfo.reqID; if (m_scene.ShuttingDown) { return; } lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } /* can't do this with current viewers; HG problem * // If the avatar is gone, don't bother to get the texture * if(m_scene.GetScenePresence(Id) == null) * { * curresponse = new Hashtable(); * curresponse["int_response_code"] = 500; * curresponse["str_response_string"] = "timeout"; * curresponse["content_type"] = "text/plain"; * curresponse["keepalive"] = false; * responses[requestID] = new APollResponse() { bytes = 0, response = curresponse }; * return; * } */ } OSHttpResponse response = new OSHttpResponse(requestinfo.request); m_getAssetHandler.Handle(requestinfo.request, response, m_hgassets); lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } APollResponse preq = new APollResponse() { osresponse = response }; responses[requestID] = preq; } }
private static void DoInventoryRequests(object o) { if (m_NumberScenes <= 0) { return; } APollRequest poolreq = o as APollRequest; if (poolreq != null && poolreq.thepoll != null) { poolreq.thepoll.Process(poolreq); } }
private static void DoAssetRequests(object o) { if (m_NumberScenes <= 0) { return; } APollRequest poolreq = o as APollRequest; if (poolreq != null && poolreq.reqID != UUID.Zero) { poolreq.thepoll.Process(poolreq); } }
public void Process(APollRequest requestinfo) { if (m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown) { return; } UUID requestID = requestinfo.reqID; lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } } OSHttpResponse osresponse = new OSHttpResponse(requestinfo.request); m_webFetchHandler.FetchInventoryDescendentsRequest(requestinfo.request, osresponse, m_module.m_badRequests); requestinfo.request.InputStream.Dispose(); lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); ProcessedRequestsCount++; return; } } Hashtable response = new Hashtable(); response["h"] = osresponse; responses[requestID] = response; } ProcessedRequestsCount++; }
public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene, string HGAssetSVC) : base(null, uri, null, null, null, null, pId, int.MaxValue) { m_scene = scene; m_hgassets = HGAssetSVC; HasEvents = (requestID, agentID) => { lock (responses) { APollResponse response; if (responses.TryGetValue(requestID, out response)) { ScenePresence sp = m_scene.GetScenePresence(pId); if (sp == null || sp.IsDeleted) { return(true); } OSHttpResponse resp = response.osresponse; if (Util.GetTimeStamp() - resp.RequestTS > (resp.RawBufferLen > 2000000 ? 200 : 90)) { return(sp.CapCanSendAsset(2, resp.RawBufferLen)); } if (resp.Priority > 1) { return(sp.CapCanSendAsset(1, resp.RawBufferLen)); } return(sp.CapCanSendAsset(2, resp.RawBufferLen)); } return(false); } }; Drop = (requestID, y) => { lock (responses) { responses.Remove(requestID); lock (dropedResponses) dropedResponses.Add(requestID); } }; GetEvents = (requestID, y) => { lock (responses) { try { OSHttpResponse response = responses[requestID].osresponse; if (response.Priority < 0) { response.Priority = 0; } Hashtable lixo = new Hashtable(1); lixo["h"] = response; return(lixo); } finally { responses.Remove(requestID); } } }; // x is request id, y is request data hashtable Request = (requestID, request) => { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = requestID; reqinfo.request = request; m_queue.Add(reqinfo); }; // this should never happen except possible on shutdown NoEvents = (x, y) => { /* * lock (requests) * { * Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); * requests.Remove(request); * } */ Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; return(response); }; }
public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene) : base(null, uri, null, null, null, null, pId, int.MaxValue) { m_scene = scene; // x is request id, y is userid HasEvents = (x, y) => { lock (responses) { APollResponse response; if (responses.TryGetValue(x, out response)) { if (m_presence == null) { m_presence = m_scene.GetScenePresence(pId); } if (m_presence == null || m_presence.IsDeleted) { return(true); } if (response.throttle) { return(m_presence.CapCanSendAsset(1, response.bytes)); } return(m_presence.CapCanSendAsset(2, response.bytes)); } return(false); } }; Drop = (x, y) => { lock (responses) { responses.Remove(x); lock (dropedResponses) dropedResponses.Add(x); } }; GetEvents = (x, y) => { lock (responses) { try { return(responses[x].response); } finally { responses.Remove(x); } } }; // x is request id, y is request data hashtable Request = (x, y) => { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; m_queue.Add(reqinfo); }; // this should never happen except possible on shutdown NoEvents = (x, y) => { /* * lock (requests) * { * Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); * requests.Remove(request); * } */ Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; return(response); }; }
public void Process(APollRequest requestinfo) { Hashtable response; UUID requestID = requestinfo.reqID; if (m_scene.ShuttingDown) { return; } lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } if (m_presence == null) { m_presence = m_scene.GetScenePresence(Id); } if (m_presence == null || m_presence.IsDeleted) { requestinfo.send503 = true; } if (requestinfo.send503) { response = new Hashtable(); response["int_response_code"] = 503; response["str_response_string"] = "Throttled"; response["content_type"] = "text/plain"; response["keepalive"] = false; Hashtable headers = new Hashtable(); headers["Retry-After"] = 20; response["headers"] = headers; responses[requestID] = new APollResponse() { bytes = 0, response = response }; return; } } response = m_getTextureHandler.Handle(requestinfo.request); lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } responses[requestID] = new APollResponse() { bytes = (int)response["int_bytes"], response = response }; } }
public PollServiceAssetEventArgs(UUID pId, Scene scene) : base(null, "", null, null, null, null, pId, int.MaxValue) { m_scene = scene; // x is request id, y is userid HasEvents = (x, y) => { lock (responses) { APollResponse response; if (responses.TryGetValue(x, out response)) { if (m_presence == null) { m_presence = m_scene.GetScenePresence(pId); } if (m_presence == null || m_presence.IsDeleted) { return(true); } return(m_presence.CapCanSendAsset(0, response.bytes)); } return(false); } }; Drop = (x, y) => { lock (responses) { responses.Remove(x); dropedResponses.Add(x); } }; GetEvents = (x, y) => { lock (responses) { try { return(responses[x].response); } finally { responses.Remove(x); } } }; // x is request id, y is request data hashtable Request = (x, y) => { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; reqinfo.send503 = false; lock (responses) { if (responses.Count > 0 && m_queue.Count > 32) { reqinfo.send503 = true; } } m_queue.Add(reqinfo); }; // this should never happen except possible on shutdown NoEvents = (x, y) => { Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; return(response); }; }
public void Process(APollRequest requestinfo) { Hashtable response; UUID requestID = requestinfo.reqID; if (m_scene.ShuttingDown) { return; } lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } if (requestinfo.send503) { response = new Hashtable(); response["int_response_code"] = 503; response["str_response_string"] = "Throttled"; response["content_type"] = "text/plain"; response["keepalive"] = false; Hashtable headers = new Hashtable(); headers["Retry-After"] = 30; response["headers"] = headers; responses[requestID] = new APollResponse() { bytes = 0, response = response }; return; } // If the avatar is gone, don't bother to get the texture if (m_scene.GetScenePresence(Id) == null) { response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; responses[requestID] = new APollResponse() { bytes = 0, response = response }; return; } } response = m_getTextureHandler.Handle(requestinfo.request); lock (responses) { lock (dropedResponses) { if (dropedResponses.Contains(requestID)) { dropedResponses.Remove(requestID); return; } } responses[requestID] = new APollResponse() { bytes = (int)response["int_bytes"], response = response }; } }
public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) : base(null, uri, null, null, null, null, pId, int.MaxValue) { m_scene = scene; m_throttler = new MeshCapsDataThrottler(100000); // x is request id, y is userid HasEvents = (x, y) => { lock (responses) { bool ret = m_throttler.hasEvents(x, responses); return(ret); } }; Drop = (x, y) => { lock (responses) { responses.Remove(x); lock (dropedResponses) dropedResponses.Add(x); } }; GetEvents = (x, y) => { lock (responses) { try { return(responses[x].response); } finally { responses.Remove(x); m_throttler.PassTime(); } } }; // x is request id, y is request data hashtable Request = (x, y) => { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; m_queue.Add(reqinfo); m_throttler.PassTime(); }; // this should never happen except possible on shutdown NoEvents = (x, y) => { /* * lock (requests) * { * Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); * requests.Remove(request); * } */ Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; return(response); }; }
public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : base(null, url, null, null, null, null, pId, int.MaxValue) { m_module = module; HasEvents = (x, y) => { lock (responses) return(responses.ContainsKey(x)); }; Drop = (x, y) => { lock (responses) { responses.Remove(x); lock (dropedResponses) dropedResponses.Add(x); } }; GetEvents = (x, y) => { lock (responses) { try { return(responses[x]); } finally { responses.Remove(x); } } }; Request = (x, y) => { ScenePresence sp = m_module.Scene.GetScenePresence(Id); APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; reqinfo.presence = sp; /* why where we doing this? just to get cof ? * List<UUID> folders = new List<UUID>(); * * // Decode the request here * string request = y["body"].ToString(); * * request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); * * request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); * request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); * * Hashtable hash = new Hashtable(); * try * { * hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); * } * catch (LLSD.LLSDParseException e) * { * m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace); * m_log.Error("Request: " + request); * return; * } * catch (System.Xml.XmlException) * { * m_log.ErrorFormat("[INVENTORY]: XML Format error"); * } * * ArrayList foldersrequested = (ArrayList)hash["folders"]; * * bool highPriority = false; * * for (int i = 0; i < foldersrequested.Count; i++) * { * Hashtable inventoryhash = (Hashtable)foldersrequested[i]; * string folder = inventoryhash["folder_id"].ToString(); * UUID folderID; * if (UUID.TryParse(folder, out folderID)) * { * if (!folders.Contains(folderID)) * { * if (sp.COF != UUID.Zero && sp.COF == folderID) * highPriority = true; * folders.Add(folderID); * } * } * } * * if (highPriority) * m_queue.PriorityEnqueue(reqinfo); * else */ m_queue.Add(reqinfo); }; NoEvents = (x, y) => { /* * lock (requests) * { * Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); * requests.Remove(request); * } */ Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; return(response); }; }
public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene, string HGAssetSVC) : base(null, uri, null, null, null, null, pId, int.MaxValue) { m_scene = scene; m_hgassets = HGAssetSVC; HasEvents = (requestID, agentID) => { lock (responses) { return(responses.ContainsKey(requestID)); } }; Drop = (requestID, y) => { lock (responses) { responses.Remove(requestID); lock (dropedResponses) dropedResponses.Add(requestID); } }; GetEvents = (requestID, y) => { lock (responses) { try { OSHttpResponse response = responses[requestID].osresponse; if (response.Priority < 0) { response.Priority = 0; } Hashtable lixo = new Hashtable(1); lixo["h"] = response; return(lixo); } finally { responses.Remove(requestID); } } }; // x is request id, y is request data hashtable Request = (requestID, request) => { APollRequest reqinfo = new APollRequest(); reqinfo.thepoll = this; reqinfo.reqID = requestID; reqinfo.request = request; m_workerpool.Enqueue(reqinfo); return(null); }; // this should never happen except possible on shutdown NoEvents = (x, y) => { /* * lock (requests) * { * Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); * requests.Remove(request); * } */ Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; return(response); }; }