aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs99
1 files changed, 62 insertions, 37 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index c6a3e65..cbdd781 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,59 @@ 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())
238 { 254 {
239 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) 255 req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id);
256 byContextDequeue(req);
257 continue;
258 }
259
260 if(req.HttpContext.IsSending())
261 {
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 }
242 271
272 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
273 {
274 m_threadPool.QueueWorkItem(x =>
275 {
276 try
277 {
278 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
279 req.DoHTTPGruntWork(m_server, responsedata);
280 }
281 catch (ObjectDisposedException) { }
282 finally
283 {
284 byContextDequeue(req);
285 }
286 return null;
287 }, null);
288 }
289 else
290 {
291 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
292 {
243 m_threadPool.QueueWorkItem(x => 293 m_threadPool.QueueWorkItem(x =>
244 { 294 {
245 try 295 try
246 { 296 {
247 req.DoHTTPGruntWork(m_server, responsedata); 297 req.DoHTTPGruntWork(m_server,
248 } 298 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
249 catch (ObjectDisposedException)
250 {
251 } 299 }
300 catch (ObjectDisposedException) {}
252 finally 301 finally
253 { 302 {
254 byContextDequeue(req); 303 byContextDequeue(req);
@@ -258,39 +307,15 @@ namespace OpenSim.Framework.Servers.HttpServer
258 } 307 }
259 else 308 else
260 { 309 {
261 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) 310 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 } 311 }
286 } 312 }
287 catch (Exception e) 313 }
288 { 314 catch (Exception e)
289 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); 315 {
290 } 316 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
291 } 317 }
292 } 318 }
293 } 319 }
294
295 } 320 }
296} 321}