diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
4 files changed, 69 insertions, 50 deletions
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 | |||