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 c6a3e65..415c264 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) |
@@ -232,23 +245,64 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
232 | { | 245 | { |
233 | PollServiceHttpRequest req = m_requests.Dequeue(4500); | 246 | PollServiceHttpRequest req = m_requests.Dequeue(4500); |
234 | Watchdog.UpdateThread(); | 247 | Watchdog.UpdateThread(); |
235 | if (req != null) | 248 | if(req == null) |
249 | continue; | ||
250 | |||
251 | try | ||
236 | { | 252 | { |
237 | try | 253 | if(!req.HttpContext.CanSend()) |
254 | { | ||
255 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); | ||
256 | byContextDequeue(req); | ||
257 | continue; | ||
258 | } | ||
259 | |||
260 | if(req.HttpContext.IsSending()) | ||
238 | { | 261 | { |
239 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 262 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) |
240 | { | 263 | { |
241 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 264 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
265 | byContextDequeue(req); | ||
266 | } | ||
267 | else | ||
268 | ReQueueEvent(req); | ||
269 | continue; | ||
270 | } | ||
271 | |||
272 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | ||
273 | { | ||
274 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
242 | 275 | ||
276 | m_threadPool.QueueWorkItem(x => | ||
277 | { | ||
278 | try | ||
279 | { | ||
280 | req.DoHTTPGruntWork(m_server, responsedata); | ||
281 | } | ||
282 | catch (ObjectDisposedException) { } | ||
283 | finally | ||
284 | { | ||
285 | if(req.HttpContext.CanSend() && req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Poll | ||
286 | && (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
287 | ReQueueEvent(req); | ||
288 | else | ||
289 | byContextDequeue(req); | ||
290 | } | ||
291 | return null; | ||
292 | }, null); | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
297 | { | ||
243 | m_threadPool.QueueWorkItem(x => | 298 | m_threadPool.QueueWorkItem(x => |
244 | { | 299 | { |
245 | try | 300 | try |
246 | { | 301 | { |
247 | req.DoHTTPGruntWork(m_server, responsedata); | 302 | req.DoHTTPGruntWork(m_server, |
248 | } | 303 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); |
249 | catch (ObjectDisposedException) | ||
250 | { | ||
251 | } | 304 | } |
305 | catch (ObjectDisposedException) {} | ||
252 | finally | 306 | finally |
253 | { | 307 | { |
254 | byContextDequeue(req); | 308 | byContextDequeue(req); |
@@ -258,39 +312,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
258 | } | 312 | } |
259 | else | 313 | else |
260 | { | 314 | { |
261 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 315 | ReQueueEvent(req); |
262 | { | ||
263 | m_threadPool.QueueWorkItem(x => | ||
264 | { | ||
265 | try | ||
266 | { | ||
267 | req.DoHTTPGruntWork(m_server, | ||
268 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
269 | } | ||
270 | catch (ObjectDisposedException) | ||
271 | { | ||
272 | // Ignore it, no need to reply | ||
273 | } | ||
274 | finally | ||
275 | { | ||
276 | byContextDequeue(req); | ||
277 | } | ||
278 | return null; | ||
279 | }, null); | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | ReQueueEvent(req); | ||
284 | } | ||
285 | } | 316 | } |
286 | } | 317 | } |
287 | catch (Exception e) | 318 | } |
288 | { | 319 | catch (Exception e) |
289 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 320 | { |
290 | } | 321 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
291 | } | 322 | } |
292 | } | 323 | } |
293 | } | 324 | } |
294 | |||
295 | } | 325 | } |
296 | } | 326 | } |