diff options
author | UbitUmarov | 2016-07-17 13:20:56 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-17 13:20:56 +0100 |
commit | 442b27222828381a27c7c5eddc967a0de4c82d0a (patch) | |
tree | 039edaa2e0a3485149e529bfb0f5ce014d6c2fc5 /OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |
parent | identify contexts by ID now avaiable ( pipeline serialization) (diff) | |
download | opensim-SC-442b27222828381a27c7c5eddc967a0de4c82d0a.zip opensim-SC-442b27222828381a27c7c5eddc967a0de4c82d0a.tar.gz opensim-SC-442b27222828381a27c7c5eddc967a0de4c82d0a.tar.bz2 opensim-SC-442b27222828381a27c7c5eddc967a0de4c82d0a.tar.xz |
add a Drop method to PollService Event handlers, Drop requests on connections known to be lost or delay event check if they are sending a response
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index ffcad0f..5b40590 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -160,6 +160,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | public void DropByContext(PollServiceHttpRequest req) | ||
164 | { | ||
165 | Queue<PollServiceHttpRequest> ctxQeueue; | ||
166 | lock (m_bycontext) | ||
167 | { | ||
168 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | ||
169 | { | ||
170 | ctxQeueue.Clear(); | ||
171 | m_bycontext.Remove(req); | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | |||
163 | public void EnqueueInt(PollServiceHttpRequest req) | 176 | public void EnqueueInt(PollServiceHttpRequest req) |
164 | { | 177 | { |
165 | if (m_running) | 178 | if (m_running) |
@@ -263,22 +276,61 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
263 | PollServiceHttpRequest req = m_requests.Dequeue(5000); | 276 | PollServiceHttpRequest req = m_requests.Dequeue(5000); |
264 | 277 | ||
265 | Watchdog.UpdateThread(); | 278 | Watchdog.UpdateThread(); |
266 | if (req != null) | 279 | if(req == null) |
280 | continue; | ||
281 | |||
282 | try | ||
267 | { | 283 | { |
268 | try | 284 | if(!req.HttpContext.CanSend()) |
269 | { | 285 | { |
270 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 286 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
287 | byContextDequeue(req); | ||
288 | continue; | ||
289 | } | ||
290 | |||
291 | if(req.HttpContext.IsSending()) | ||
292 | { | ||
293 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
271 | { | 294 | { |
272 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 295 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
296 | byContextDequeue(req); | ||
297 | } | ||
298 | else | ||
299 | ReQueueEvent(req); | ||
300 | continue; | ||
301 | } | ||
273 | 302 | ||
303 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | ||
304 | { | ||
305 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
306 | |||
307 | m_threadPool.QueueWorkItem(x => | ||
308 | { | ||
309 | try | ||
310 | { | ||
311 | req.DoHTTPGruntWork(m_server, responsedata); | ||
312 | byContextDequeue(req); | ||
313 | } | ||
314 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | ||
315 | { | ||
316 | // Ignore it, no need to reply | ||
317 | } | ||
318 | return null; | ||
319 | }, null); | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
324 | { | ||
274 | m_threadPool.QueueWorkItem(x => | 325 | m_threadPool.QueueWorkItem(x => |
275 | { | 326 | { |
276 | try | 327 | try |
277 | { | 328 | { |
278 | req.DoHTTPGruntWork(m_server, responsedata); | 329 | req.DoHTTPGruntWork(m_server, |
330 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
279 | byContextDequeue(req); | 331 | byContextDequeue(req); |
280 | } | 332 | } |
281 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | 333 | catch (ObjectDisposedException) |
282 | { | 334 | { |
283 | // Ignore it, no need to reply | 335 | // Ignore it, no need to reply |
284 | } | 336 | } |
@@ -287,36 +339,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
287 | } | 339 | } |
288 | else | 340 | else |
289 | { | 341 | { |
290 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 342 | ReQueueEvent(req); |
291 | { | ||
292 | m_threadPool.QueueWorkItem(x => | ||
293 | { | ||
294 | try | ||
295 | { | ||
296 | req.DoHTTPGruntWork(m_server, | ||
297 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
298 | byContextDequeue(req); | ||
299 | } | ||
300 | catch (ObjectDisposedException) | ||
301 | { | ||
302 | // Ignore it, no need to reply | ||
303 | } | ||
304 | return null; | ||
305 | }, null); | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | ReQueueEvent(req); | ||
310 | } | ||
311 | } | 343 | } |
312 | } | 344 | } |
313 | catch (Exception e) | 345 | } |
314 | { | 346 | catch (Exception e) |
315 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 347 | { |
316 | } | 348 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
317 | } | 349 | } |
318 | } | 350 | } |
319 | } | 351 | } |
320 | |||
321 | } | 352 | } |
322 | } | 353 | } |