diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 104 |
1 files changed, 67 insertions, 37 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index e1bd564..94a9490 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -156,6 +156,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | public void DropByContext(PollServiceHttpRequest req) | ||
160 | { | ||
161 | Queue<PollServiceHttpRequest> ctxQeueue; | ||
162 | lock (m_bycontext) | ||
163 | { | ||
164 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | ||
165 | { | ||
166 | ctxQeueue.Clear(); | ||
167 | m_bycontext.Remove(req); | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | |||
159 | public void EnqueueInt(PollServiceHttpRequest req) | 172 | public void EnqueueInt(PollServiceHttpRequest req) |
160 | { | 173 | { |
161 | if (m_running) | 174 | if (m_running) |
@@ -234,23 +247,64 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
234 | { | 247 | { |
235 | PollServiceHttpRequest req = m_requests.Dequeue(5000); | 248 | PollServiceHttpRequest req = m_requests.Dequeue(5000); |
236 | Watchdog.UpdateThread(); | 249 | Watchdog.UpdateThread(); |
237 | if (req != null) | 250 | if(req == null) |
251 | continue; | ||
252 | |||
253 | try | ||
238 | { | 254 | { |
239 | try | 255 | if(!req.HttpContext.CanSend()) |
256 | { | ||
257 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); | ||
258 | byContextDequeue(req); | ||
259 | continue; | ||
260 | } | ||
261 | |||
262 | if(req.HttpContext.IsSending()) | ||
240 | { | 263 | { |
241 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 264 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) |
242 | { | 265 | { |
243 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 266 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
267 | byContextDequeue(req); | ||
268 | } | ||
269 | else | ||
270 | ReQueueEvent(req); | ||
271 | continue; | ||
272 | } | ||
273 | |||
274 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | ||
275 | { | ||
276 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
244 | 277 | ||
278 | m_threadPool.QueueWorkItem(x => | ||
279 | { | ||
280 | try | ||
281 | { | ||
282 | req.DoHTTPGruntWork(m_server, responsedata); | ||
283 | } | ||
284 | catch (ObjectDisposedException) { } | ||
285 | finally | ||
286 | { | ||
287 | if(req.HttpContext.CanSend() && req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Poll | ||
288 | && (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
289 | ReQueueEvent(req); | ||
290 | else | ||
291 | byContextDequeue(req); | ||
292 | } | ||
293 | return null; | ||
294 | }, null); | ||
295 | } | ||
296 | else | ||
297 | { | ||
298 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
299 | { | ||
245 | m_threadPool.QueueWorkItem(x => | 300 | m_threadPool.QueueWorkItem(x => |
246 | { | 301 | { |
247 | try | 302 | try |
248 | { | 303 | { |
249 | req.DoHTTPGruntWork(m_server, responsedata); | 304 | req.DoHTTPGruntWork(m_server, |
250 | } | 305 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); |
251 | catch (ObjectDisposedException) | ||
252 | { | ||
253 | } | 306 | } |
307 | catch (ObjectDisposedException) {} | ||
254 | finally | 308 | finally |
255 | { | 309 | { |
256 | byContextDequeue(req); | 310 | byContextDequeue(req); |
@@ -260,39 +314,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
260 | } | 314 | } |
261 | else | 315 | else |
262 | { | 316 | { |
263 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 317 | ReQueueEvent(req); |
264 | { | ||
265 | m_threadPool.QueueWorkItem(x => | ||
266 | { | ||
267 | try | ||
268 | { | ||
269 | req.DoHTTPGruntWork(m_server, | ||
270 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
271 | } | ||
272 | catch (ObjectDisposedException) | ||
273 | { | ||
274 | // Ignore it, no need to reply | ||
275 | } | ||
276 | finally | ||
277 | { | ||
278 | byContextDequeue(req); | ||
279 | } | ||
280 | return null; | ||
281 | }, null); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | ReQueueEvent(req); | ||
286 | } | ||
287 | } | 318 | } |
288 | } | 319 | } |
289 | catch (Exception e) | 320 | } |
290 | { | 321 | catch (Exception e) |
291 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 322 | { |
292 | } | 323 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
293 | } | 324 | } |
294 | } | 325 | } |
295 | } | 326 | } |
296 | |||
297 | } | 327 | } |
298 | } | 328 | } |