diff options
author | Justin Clark-Casey (justincc) | 2013-07-15 23:22:39 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-07-15 23:27:46 +0100 |
commit | 1b7b664c8696531fec26378d1386362d8a3da55e (patch) | |
tree | 1bdf9c56b647c7d5fa47289ec8323c4d35ae09ca | |
parent | Reinsert PhysicsActor variable back into SOP.SubscribeForCollisionEvents() in... (diff) | |
download | opensim-SC-1b7b664c8696531fec26378d1386362d8a3da55e.zip opensim-SC-1b7b664c8696531fec26378d1386362d8a3da55e.tar.gz opensim-SC-1b7b664c8696531fec26378d1386362d8a3da55e.tar.bz2 opensim-SC-1b7b664c8696531fec26378d1386362d8a3da55e.tar.xz |
Add request received/handling stats for caps which are served by http poll handlers.
This adds explicit cap poll handler supporting to the Caps classes rather than relying on callers to do the complicated coding.
Other refactoring was required to get logic into the right places to support this.
11 files changed, 267 insertions, 126 deletions
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs index 6c95d8b..bbf3b27 100644 --- a/OpenSim/Capabilities/Caps.cs +++ b/OpenSim/Capabilities/Caps.cs | |||
@@ -63,7 +63,11 @@ namespace OpenSim.Framework.Capabilities | |||
63 | public string CapsObjectPath { get { return m_capsObjectPath; } } | 63 | public string CapsObjectPath { get { return m_capsObjectPath; } } |
64 | 64 | ||
65 | private CapsHandlers m_capsHandlers; | 65 | private CapsHandlers m_capsHandlers; |
66 | private Dictionary<string, string> m_externalCapsHandlers; | 66 | |
67 | private Dictionary<string, PollServiceEventArgs> m_pollServiceHandlers | ||
68 | = new Dictionary<string, PollServiceEventArgs>(); | ||
69 | |||
70 | private Dictionary<string, string> m_externalCapsHandlers = new Dictionary<string, string>(); | ||
67 | 71 | ||
68 | private IHttpServer m_httpListener; | 72 | private IHttpServer m_httpListener; |
69 | private UUID m_agentID; | 73 | private UUID m_agentID; |
@@ -132,7 +136,6 @@ namespace OpenSim.Framework.Capabilities | |||
132 | 136 | ||
133 | m_agentID = agent; | 137 | m_agentID = agent; |
134 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); | 138 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); |
135 | m_externalCapsHandlers = new Dictionary<string, string>(); | ||
136 | m_regionName = regionName; | 139 | m_regionName = regionName; |
137 | } | 140 | } |
138 | 141 | ||
@@ -147,6 +150,27 @@ namespace OpenSim.Framework.Capabilities | |||
147 | m_capsHandlers[capName] = handler; | 150 | m_capsHandlers[capName] = handler; |
148 | } | 151 | } |
149 | 152 | ||
153 | public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler) | ||
154 | { | ||
155 | m_pollServiceHandlers.Add(capName, pollServiceHandler); | ||
156 | |||
157 | m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler); | ||
158 | |||
159 | // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
160 | // string protocol = "http"; | ||
161 | // string hostName = m_httpListenerHostName; | ||
162 | // | ||
163 | // if (MainServer.Instance.UseSSL) | ||
164 | // { | ||
165 | // hostName = MainServer.Instance.SSLCommonName; | ||
166 | // port = MainServer.Instance.SSLPort; | ||
167 | // protocol = "https"; | ||
168 | // } | ||
169 | |||
170 | // RegisterHandler( | ||
171 | // capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url)); | ||
172 | } | ||
173 | |||
150 | /// <summary> | 174 | /// <summary> |
151 | /// Register an external handler. The service for this capability is somewhere else | 175 | /// Register an external handler. The service for this capability is somewhere else |
152 | /// given by the URL. | 176 | /// given by the URL. |
@@ -163,13 +187,70 @@ namespace OpenSim.Framework.Capabilities | |||
163 | /// </summary> | 187 | /// </summary> |
164 | public void DeregisterHandlers() | 188 | public void DeregisterHandlers() |
165 | { | 189 | { |
166 | if (m_capsHandlers != null) | 190 | foreach (string capsName in m_capsHandlers.Caps) |
191 | { | ||
192 | m_capsHandlers.Remove(capsName); | ||
193 | } | ||
194 | |||
195 | foreach (PollServiceEventArgs handler in m_pollServiceHandlers.Values) | ||
196 | { | ||
197 | m_httpListener.RemovePollServiceHTTPHandler("", handler.Url); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | public bool TryGetPollHandler(string name, out PollServiceEventArgs pollHandler) | ||
202 | { | ||
203 | return m_pollServiceHandlers.TryGetValue(name, out pollHandler); | ||
204 | } | ||
205 | |||
206 | public Dictionary<string, PollServiceEventArgs> GetPollHandlers() | ||
207 | { | ||
208 | return new Dictionary<string, PollServiceEventArgs>(m_pollServiceHandlers); | ||
209 | } | ||
210 | |||
211 | /// <summary> | ||
212 | /// Return an LLSD-serializable Hashtable describing the | ||
213 | /// capabilities and their handler details. | ||
214 | /// </summary> | ||
215 | /// <param name="excludeSeed">If true, then exclude the seed cap.</param> | ||
216 | public Hashtable GetCapsDetails(bool excludeSeed, List<string> requestedCaps) | ||
217 | { | ||
218 | Hashtable caps = CapsHandlers.GetCapsDetails(excludeSeed, requestedCaps); | ||
219 | |||
220 | lock (m_pollServiceHandlers) | ||
167 | { | 221 | { |
168 | foreach (string capsName in m_capsHandlers.Caps) | 222 | foreach (KeyValuePair <string, PollServiceEventArgs> kvp in m_pollServiceHandlers) |
169 | { | 223 | { |
170 | m_capsHandlers.Remove(capsName); | 224 | if (!requestedCaps.Contains(kvp.Key)) |
225 | continue; | ||
226 | |||
227 | string hostName = m_httpListenerHostName; | ||
228 | uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
229 | string protocol = "http"; | ||
230 | |||
231 | if (MainServer.Instance.UseSSL) | ||
232 | { | ||
233 | hostName = MainServer.Instance.SSLCommonName; | ||
234 | port = MainServer.Instance.SSLPort; | ||
235 | protocol = "https"; | ||
236 | } | ||
237 | // | ||
238 | // caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | ||
239 | |||
240 | caps[kvp.Key] = string.Format("{0}://{1}:{2}{3}", protocol, hostName, port, kvp.Value.Url); | ||
171 | } | 241 | } |
172 | } | 242 | } |
243 | |||
244 | // Add the external too | ||
245 | foreach (KeyValuePair<string, string> kvp in ExternalCapsHandlers) | ||
246 | { | ||
247 | if (!requestedCaps.Contains(kvp.Key)) | ||
248 | continue; | ||
249 | |||
250 | caps[kvp.Key] = kvp.Value; | ||
251 | } | ||
252 | |||
253 | return caps; | ||
173 | } | 254 | } |
174 | } | 255 | } |
175 | } | 256 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 3e3c2b3..8ad7b0d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console | |||
234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
235 | 235 | ||
236 | m_Server.AddPollServiceHTTPHandler( | 236 | m_Server.AddPollServiceHTTPHandler( |
237 | uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout | 237 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout |
238 | 238 | ||
239 | XmlDocument xmldoc = new XmlDocument(); | 239 | XmlDocument xmldoc = new XmlDocument(); |
240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 6863e0e..c4e569d 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -387,6 +387,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
387 | 387 | ||
388 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) | 388 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) |
389 | { | 389 | { |
390 | psEvArgs.RequestsReceived++; | ||
391 | |||
390 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); | 392 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); |
391 | 393 | ||
392 | if (psEvArgs.Request != null) | 394 | if (psEvArgs.Request != null) |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 3079a7e..020bfd5 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | |||
@@ -55,12 +55,26 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
55 | Inventory = 2 | 55 | Inventory = 2 |
56 | } | 56 | } |
57 | 57 | ||
58 | public string Url { get; set; } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Number of requests received for this poll service. | ||
62 | /// </summary> | ||
63 | public int RequestsReceived { get; set; } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Number of requests handled by this poll service. | ||
67 | /// </summary> | ||
68 | public int RequestsHandled { get; set; } | ||
69 | |||
58 | public PollServiceEventArgs( | 70 | public PollServiceEventArgs( |
59 | RequestMethod pRequest, | 71 | RequestMethod pRequest, |
72 | string pUrl, | ||
60 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, | 73 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, |
61 | UUID pId, int pTimeOutms) | 74 | UUID pId, int pTimeOutms) |
62 | { | 75 | { |
63 | Request = pRequest; | 76 | Request = pRequest; |
77 | Url = pUrl; | ||
64 | HasEvents = pHasEvents; | 78 | HasEvents = pHasEvents; |
65 | GetEvents = pGetEvents; | 79 | GetEvents = pGetEvents; |
66 | NoEvents = pNoEvents; | 80 | NoEvents = pNoEvents; |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 723530a..6aa9479 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -26,13 +26,19 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
29 | using HttpServer; | 32 | using HttpServer; |
33 | using log4net; | ||
30 | using OpenMetaverse; | 34 | using OpenMetaverse; |
31 | 35 | ||
32 | namespace OpenSim.Framework.Servers.HttpServer | 36 | namespace OpenSim.Framework.Servers.HttpServer |
33 | { | 37 | { |
34 | public class PollServiceHttpRequest | 38 | public class PollServiceHttpRequest |
35 | { | 39 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
36 | public readonly PollServiceEventArgs PollServiceArgs; | 42 | public readonly PollServiceEventArgs PollServiceArgs; |
37 | public readonly IHttpClientContext HttpContext; | 43 | public readonly IHttpClientContext HttpContext; |
38 | public readonly IHttpRequest Request; | 44 | public readonly IHttpRequest Request; |
@@ -48,5 +54,44 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
48 | RequestTime = System.Environment.TickCount; | 54 | RequestTime = System.Environment.TickCount; |
49 | RequestID = UUID.Random(); | 55 | RequestID = UUID.Random(); |
50 | } | 56 | } |
57 | |||
58 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) | ||
59 | { | ||
60 | OSHttpResponse response | ||
61 | = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); | ||
62 | |||
63 | byte[] buffer = server.DoHTTPGruntWork(responsedata, response); | ||
64 | |||
65 | response.SendChunked = false; | ||
66 | response.ContentLength64 = buffer.Length; | ||
67 | response.ContentEncoding = Encoding.UTF8; | ||
68 | |||
69 | try | ||
70 | { | ||
71 | response.OutputStream.Write(buffer, 0, buffer.Length); | ||
72 | } | ||
73 | catch (Exception ex) | ||
74 | { | ||
75 | m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex)); | ||
76 | } | ||
77 | finally | ||
78 | { | ||
79 | //response.OutputStream.Close(); | ||
80 | try | ||
81 | { | ||
82 | response.OutputStream.Flush(); | ||
83 | response.Send(); | ||
84 | |||
85 | //if (!response.KeepAlive && response.ReuseContext) | ||
86 | // response.FreeContext(); | ||
87 | } | ||
88 | catch (Exception e) | ||
89 | { | ||
90 | m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e)); | ||
91 | } | ||
92 | |||
93 | PollServiceArgs.RequestsHandled++; | ||
94 | } | ||
95 | } | ||
51 | } | 96 | } |
52 | } \ No newline at end of file | 97 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index aee3e3c..1b9010a 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -157,8 +157,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
157 | { | 157 | { |
158 | foreach (PollServiceHttpRequest req in m_retryRequests) | 158 | foreach (PollServiceHttpRequest req in m_retryRequests) |
159 | { | 159 | { |
160 | DoHTTPGruntWork(m_server,req, | 160 | req.DoHTTPGruntWork(m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); |
161 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
162 | } | 161 | } |
163 | } | 162 | } |
164 | catch | 163 | catch |
@@ -179,8 +178,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
179 | try | 178 | try |
180 | { | 179 | { |
181 | wreq = m_requests.Dequeue(0); | 180 | wreq = m_requests.Dequeue(0); |
182 | DoHTTPGruntWork(m_server,wreq, | 181 | wreq.DoHTTPGruntWork( |
183 | wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id)); | 182 | m_server, wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id)); |
184 | } | 183 | } |
185 | catch | 184 | catch |
186 | { | 185 | { |
@@ -214,7 +213,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
214 | { | 213 | { |
215 | try | 214 | try |
216 | { | 215 | { |
217 | DoHTTPGruntWork(m_server, req, responsedata); | 216 | req.DoHTTPGruntWork(m_server, responsedata); |
218 | } | 217 | } |
219 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | 218 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream |
220 | { | 219 | { |
@@ -227,7 +226,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
227 | { | 226 | { |
228 | try | 227 | try |
229 | { | 228 | { |
230 | DoHTTPGruntWork(m_server, req, responsedata); | 229 | req.DoHTTPGruntWork(m_server, responsedata); |
231 | } | 230 | } |
232 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | 231 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream |
233 | { | 232 | { |
@@ -242,8 +241,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
242 | { | 241 | { |
243 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 242 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) |
244 | { | 243 | { |
245 | DoHTTPGruntWork(m_server, req, | 244 | req.DoHTTPGruntWork( |
246 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | 245 | m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); |
247 | } | 246 | } |
248 | else | 247 | else |
249 | { | 248 | { |
@@ -258,46 +257,5 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
258 | } | 257 | } |
259 | } | 258 | } |
260 | } | 259 | } |
261 | |||
262 | // DoHTTPGruntWork changed, not sending response | ||
263 | // do the same work around as core | ||
264 | |||
265 | internal static void DoHTTPGruntWork(BaseHttpServer server, PollServiceHttpRequest req, Hashtable responsedata) | ||
266 | { | ||
267 | OSHttpResponse response | ||
268 | = new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext); | ||
269 | |||
270 | byte[] buffer = server.DoHTTPGruntWork(responsedata, response); | ||
271 | |||
272 | response.SendChunked = false; | ||
273 | response.ContentLength64 = buffer.Length; | ||
274 | response.ContentEncoding = Encoding.UTF8; | ||
275 | |||
276 | try | ||
277 | { | ||
278 | response.OutputStream.Write(buffer, 0, buffer.Length); | ||
279 | } | ||
280 | catch (Exception ex) | ||
281 | { | ||
282 | m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex)); | ||
283 | } | ||
284 | finally | ||
285 | { | ||
286 | //response.OutputStream.Close(); | ||
287 | try | ||
288 | { | ||
289 | response.OutputStream.Flush(); | ||
290 | response.Send(); | ||
291 | |||
292 | //if (!response.KeepAlive && response.ReuseContext) | ||
293 | // response.FreeContext(); | ||
294 | } | ||
295 | catch (Exception e) | ||
296 | { | ||
297 | m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e)); | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | } | 260 | } |
302 | } | 261 | } \ No newline at end of file |
303 | |||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 5c6bc1c..1d4c7f0 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -285,18 +285,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
285 | foreach (OSD c in capsRequested) | 285 | foreach (OSD c in capsRequested) |
286 | validCaps.Add(c.AsString()); | 286 | validCaps.Add(c.AsString()); |
287 | 287 | ||
288 | Hashtable caps = m_HostCapsObj.CapsHandlers.GetCapsDetails(true, validCaps); | 288 | string result = LLSDHelpers.SerialiseLLSDReply(m_HostCapsObj.GetCapsDetails(true, validCaps)); |
289 | |||
290 | // Add the external too | ||
291 | foreach (KeyValuePair<string, string> kvp in m_HostCapsObj.ExternalCapsHandlers) | ||
292 | { | ||
293 | if (!validCaps.Contains(kvp.Key)) | ||
294 | continue; | ||
295 | |||
296 | caps[kvp.Key] = kvp.Value; | ||
297 | } | ||
298 | |||
299 | string result = LLSDHelpers.SerialiseLLSDReply(caps); | ||
300 | 289 | ||
301 | //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); | 290 | //m_log.DebugFormat("[CAPS] CapsRequest {0}", result); |
302 | 291 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 50bfda1..ca38a97 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
377 | // TODO: Add EventQueueGet name/description for diagnostics | 377 | // TODO: Add EventQueueGet name/description for diagnostics |
378 | MainServer.Instance.AddPollServiceHTTPHandler( | 378 | MainServer.Instance.AddPollServiceHTTPHandler( |
379 | eventQueueGetPath, | 379 | eventQueueGetPath, |
380 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 40000)); | 380 | new PollServiceEventArgs(null, eventQueueGetPath, HasEvents, GetEvents, NoEvents, agentID, 40000)); |
381 | 381 | ||
382 | // m_log.DebugFormat( | 382 | // m_log.DebugFormat( |
383 | // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", | 383 | // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index b90df17..86a0298 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -77,7 +77,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
77 | 77 | ||
78 | private static WebFetchInvDescHandler m_webFetchHandler; | 78 | private static WebFetchInvDescHandler m_webFetchHandler; |
79 | 79 | ||
80 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); | ||
81 | private static Thread[] m_workerThreads = null; | 80 | private static Thread[] m_workerThreads = null; |
82 | 81 | ||
83 | private static DoubleQueue<aPollRequest> m_queue = | 82 | private static DoubleQueue<aPollRequest> m_queue = |
@@ -114,7 +113,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
114 | return; | 113 | return; |
115 | 114 | ||
116 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | 115 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; |
117 | m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; | ||
118 | 116 | ||
119 | foreach (Thread t in m_workerThreads) | 117 | foreach (Thread t in m_workerThreads) |
120 | Watchdog.AbortThread(t.ManagedThreadId); | 118 | Watchdog.AbortThread(t.ManagedThreadId); |
@@ -134,7 +132,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
134 | m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); | 132 | m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); |
135 | 133 | ||
136 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 134 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
137 | m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; | ||
138 | 135 | ||
139 | if (m_workerThreads == null) | 136 | if (m_workerThreads == null) |
140 | { | 137 | { |
@@ -177,8 +174,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
177 | 174 | ||
178 | private Scene m_scene; | 175 | private Scene m_scene; |
179 | 176 | ||
180 | public PollServiceInventoryEventArgs(Scene scene, UUID pId) : | 177 | public PollServiceInventoryEventArgs(Scene scene, string url, UUID pId) : |
181 | base(null, null, null, null, pId, int.MaxValue) | 178 | base(null, url, null, null, null, pId, int.MaxValue) |
182 | { | 179 | { |
183 | m_scene = scene; | 180 | m_scene = scene; |
184 | 181 | ||
@@ -308,40 +305,39 @@ namespace OpenSim.Region.ClientStack.Linden | |||
308 | if (m_fetchInventoryDescendents2Url == "") | 305 | if (m_fetchInventoryDescendents2Url == "") |
309 | return; | 306 | return; |
310 | 307 | ||
311 | string capUrl = "/CAPS/" + UUID.Random() + "/"; | ||
312 | |||
313 | // Register this as a poll service | 308 | // Register this as a poll service |
314 | PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, agentID); | 309 | PollServiceInventoryEventArgs args |
315 | 310 | = new PollServiceInventoryEventArgs(m_scene, "/CAPS/" + UUID.Random() + "/", agentID); | |
316 | args.Type = PollServiceEventArgs.EventType.Inventory; | 311 | args.Type = PollServiceEventArgs.EventType.Inventory; |
317 | MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); | ||
318 | |||
319 | string hostName = m_scene.RegionInfo.ExternalHostName; | ||
320 | uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
321 | string protocol = "http"; | ||
322 | |||
323 | if (MainServer.Instance.UseSSL) | ||
324 | { | ||
325 | hostName = MainServer.Instance.SSLCommonName; | ||
326 | port = MainServer.Instance.SSLPort; | ||
327 | protocol = "https"; | ||
328 | } | ||
329 | |||
330 | caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | ||
331 | 312 | ||
332 | m_capsDict[agentID] = capUrl; | 313 | caps.RegisterPollHandler("FetchInventoryDescendents2", args); |
314 | |||
315 | // MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); | ||
316 | // | ||
317 | // string hostName = m_scene.RegionInfo.ExternalHostName; | ||
318 | // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
319 | // string protocol = "http"; | ||
320 | // | ||
321 | // if (MainServer.Instance.UseSSL) | ||
322 | // { | ||
323 | // hostName = MainServer.Instance.SSLCommonName; | ||
324 | // port = MainServer.Instance.SSLPort; | ||
325 | // protocol = "https"; | ||
326 | // } | ||
327 | // | ||
328 | // caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | ||
333 | } | 329 | } |
334 | 330 | ||
335 | private void DeregisterCaps(UUID agentID, Caps caps) | 331 | // private void DeregisterCaps(UUID agentID, Caps caps) |
336 | { | 332 | // { |
337 | string capUrl; | 333 | // string capUrl; |
338 | 334 | // | |
339 | if (m_capsDict.TryGetValue(agentID, out capUrl)) | 335 | // if (m_capsDict.TryGetValue(agentID, out capUrl)) |
340 | { | 336 | // { |
341 | MainServer.Instance.RemoveHTTPHandler("", capUrl); | 337 | // MainServer.Instance.RemoveHTTPHandler("", capUrl); |
342 | m_capsDict.Remove(agentID); | 338 | // m_capsDict.Remove(agentID); |
343 | } | 339 | // } |
344 | } | 340 | // } |
345 | 341 | ||
346 | private void DoInventoryRequests() | 342 | private void DoInventoryRequests() |
347 | { | 343 | { |
@@ -355,4 +351,4 @@ namespace OpenSim.Region.ClientStack.Linden | |||
355 | } | 351 | } |
356 | } | 352 | } |
357 | } | 353 | } |
358 | } | 354 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index bd60611..ad1c4ce 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
80 | 80 | ||
81 | MainConsole.Instance.Commands.AddCommand( | 81 | MainConsole.Instance.Commands.AddCommand( |
82 | "Comms", false, "show caps stats by user", | 82 | "Comms", false, "show caps stats by user", |
83 | "show caps stats [<first-name> <last-name>]", | 83 | "show caps stats by user [<first-name> <last-name>]", |
84 | "Shows statistics on capabilities use by user.", | 84 | "Shows statistics on capabilities use by user.", |
85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", | 85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", |
86 | HandleShowCapsStatsByUserCommand); | 86 | HandleShowCapsStatsByUserCommand); |
@@ -285,27 +285,31 @@ namespace OpenSim.Region.CoreModules.Framework | |||
285 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | 285 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) |
286 | return; | 286 | return; |
287 | 287 | ||
288 | StringBuilder caps = new StringBuilder(); | 288 | StringBuilder capsReport = new StringBuilder(); |
289 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | 289 | capsReport.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); |
290 | 290 | ||
291 | lock (m_capsObjects) | 291 | lock (m_capsObjects) |
292 | { | 292 | { |
293 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) | 293 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) |
294 | { | 294 | { |
295 | caps.AppendFormat("** User {0}:\n", kvp.Key); | 295 | capsReport.AppendFormat("** User {0}:\n", kvp.Key); |
296 | Caps caps = kvp.Value; | ||
296 | 297 | ||
297 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | 298 | for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) |
298 | { | 299 | { |
299 | Uri uri = new Uri(kvp2.Value.ToString()); | 300 | Uri uri = new Uri(kvp2.Value.ToString()); |
300 | caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | 301 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); |
301 | } | 302 | } |
302 | 303 | ||
303 | foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) | 304 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp2 in caps.GetPollHandlers()) |
304 | caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | 305 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url); |
306 | |||
307 | foreach (KeyValuePair<string, string> kvp3 in caps.ExternalCapsHandlers) | ||
308 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | ||
305 | } | 309 | } |
306 | } | 310 | } |
307 | 311 | ||
308 | MainConsole.Instance.Output(caps.ToString()); | 312 | MainConsole.Instance.Output(capsReport.ToString()); |
309 | } | 313 | } |
310 | 314 | ||
311 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) | 315 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) |
@@ -362,7 +366,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
362 | { | 366 | { |
363 | receivedStats[sp.Name] = reqHandler.RequestsReceived; | 367 | receivedStats[sp.Name] = reqHandler.RequestsReceived; |
364 | handledStats[sp.Name] = reqHandler.RequestsHandled; | 368 | handledStats[sp.Name] = reqHandler.RequestsHandled; |
365 | } | 369 | } |
370 | else | ||
371 | { | ||
372 | PollServiceEventArgs pollHandler = null; | ||
373 | if (caps.TryGetPollHandler(capName, out pollHandler)) | ||
374 | { | ||
375 | receivedStats[sp.Name] = pollHandler.RequestsReceived; | ||
376 | handledStats[sp.Name] = pollHandler.RequestsHandled; | ||
377 | } | ||
378 | } | ||
366 | } | 379 | } |
367 | ); | 380 | ); |
368 | 381 | ||
@@ -391,11 +404,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
391 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | 404 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); |
392 | 405 | ||
393 | if (caps == null) | 406 | if (caps == null) |
394 | return; | 407 | return; |
395 | |||
396 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
397 | 408 | ||
398 | foreach (IRequestHandler reqHandler in capsHandlers.Values) | 409 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
399 | { | 410 | { |
400 | string reqName = reqHandler.Name ?? ""; | 411 | string reqName = reqHandler.Name ?? ""; |
401 | 412 | ||
@@ -410,6 +421,23 @@ namespace OpenSim.Region.CoreModules.Framework | |||
410 | handledStats[reqName] += reqHandler.RequestsHandled; | 421 | handledStats[reqName] += reqHandler.RequestsHandled; |
411 | } | 422 | } |
412 | } | 423 | } |
424 | |||
425 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) | ||
426 | { | ||
427 | string name = kvp.Key; | ||
428 | PollServiceEventArgs pollHandler = kvp.Value; | ||
429 | |||
430 | if (!receivedStats.ContainsKey(name)) | ||
431 | { | ||
432 | receivedStats[name] = pollHandler.RequestsReceived; | ||
433 | handledStats[name] = pollHandler.RequestsHandled; | ||
434 | } | ||
435 | else | ||
436 | { | ||
437 | receivedStats[name] += pollHandler.RequestsReceived; | ||
438 | handledStats[name] += pollHandler.RequestsHandled; | ||
439 | } | ||
440 | } | ||
413 | } | 441 | } |
414 | ); | 442 | ); |
415 | 443 | ||
@@ -468,12 +496,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
468 | if (caps == null) | 496 | if (caps == null) |
469 | return; | 497 | return; |
470 | 498 | ||
471 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | 499 | List<CapTableRow> capRows = new List<CapTableRow>(); |
472 | 500 | ||
473 | foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived)) | 501 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
474 | { | 502 | capRows.Add(new CapTableRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled)); |
475 | cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled); | 503 | |
476 | } | 504 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) |
505 | capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled)); | ||
506 | |||
507 | foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived)) | ||
508 | cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); | ||
477 | 509 | ||
478 | sb.Append(cdt.ToString()); | 510 | sb.Append(cdt.ToString()); |
479 | } | 511 | } |
@@ -505,6 +537,14 @@ namespace OpenSim.Region.CoreModules.Framework | |||
505 | totalRequestsReceived += reqHandler.RequestsReceived; | 537 | totalRequestsReceived += reqHandler.RequestsReceived; |
506 | totalRequestsHandled += reqHandler.RequestsHandled; | 538 | totalRequestsHandled += reqHandler.RequestsHandled; |
507 | } | 539 | } |
540 | |||
541 | Dictionary<string, PollServiceEventArgs> capsPollHandlers = caps.GetPollHandlers(); | ||
542 | |||
543 | foreach (PollServiceEventArgs handler in capsPollHandlers.Values) | ||
544 | { | ||
545 | totalRequestsReceived += handler.RequestsReceived; | ||
546 | totalRequestsHandled += handler.RequestsHandled; | ||
547 | } | ||
508 | 548 | ||
509 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); | 549 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); |
510 | } | 550 | } |
@@ -512,5 +552,19 @@ namespace OpenSim.Region.CoreModules.Framework | |||
512 | 552 | ||
513 | sb.Append(cdt.ToString()); | 553 | sb.Append(cdt.ToString()); |
514 | } | 554 | } |
555 | |||
556 | private class CapTableRow | ||
557 | { | ||
558 | public string Name { get; set; } | ||
559 | public int RequestsReceived { get; set; } | ||
560 | public int RequestsHandled { get; set; } | ||
561 | |||
562 | public CapTableRow(string name, int requestsReceived, int requestsHandled) | ||
563 | { | ||
564 | Name = name; | ||
565 | RequestsReceived = requestsReceived; | ||
566 | RequestsHandled = requestsHandled; | ||
567 | } | ||
568 | } | ||
515 | } | 569 | } |
516 | } \ No newline at end of file | 570 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index def8162..99a3122 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -235,7 +235,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
235 | 235 | ||
236 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; | 236 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; |
237 | 237 | ||
238 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 238 | PollServiceEventArgs args |
239 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | ||
239 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 240 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
240 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); | 241 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); |
241 | 242 | ||
@@ -280,7 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
280 | 281 | ||
281 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; | 282 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; |
282 | 283 | ||
283 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 284 | PollServiceEventArgs args |
285 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | ||
284 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 286 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
285 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); | 287 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); |
286 | 288 | ||