diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 92 |
1 files changed, 40 insertions, 52 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index b8f5743..bad28e4 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -46,7 +46,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
46 | 46 | ||
47 | private readonly BaseHttpServer m_server; | 47 | private readonly BaseHttpServer m_server; |
48 | 48 | ||
49 | private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); | 49 | private DoubleQueue<PollServiceHttpRequest> m_requests = new DoubleQueue<PollServiceHttpRequest>(); |
50 | private static Queue<PollServiceHttpRequest> m_longPollRequests = new Queue<PollServiceHttpRequest>(); | 50 | private static Queue<PollServiceHttpRequest> m_longPollRequests = new Queue<PollServiceHttpRequest>(); |
51 | 51 | ||
52 | private uint m_WorkerThreadCount = 0; | 52 | private uint m_WorkerThreadCount = 0; |
@@ -163,7 +163,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
163 | m_requests.Enqueue(m_longPollRequests.Dequeue()); | 163 | m_requests.Enqueue(m_longPollRequests.Dequeue()); |
164 | } | 164 | } |
165 | 165 | ||
166 | while (m_requests.Count() > 0) | 166 | while (m_requests.Count > 0) |
167 | { | 167 | { |
168 | try | 168 | try |
169 | { | 169 | { |
@@ -185,33 +185,35 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
185 | { | 185 | { |
186 | while (m_running) | 186 | while (m_running) |
187 | { | 187 | { |
188 | Watchdog.UpdateThread(); | 188 | PollServiceHttpRequest req = m_requests.Dequeue(5000); |
189 | //m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString())); | ||
189 | 190 | ||
190 | PollServiceHttpRequest req = null; | 191 | Watchdog.UpdateThread(); |
191 | lock (m_requests) | 192 | if (req != null) |
192 | { | ||
193 | if (m_requests.Count() > 0) | ||
194 | req = m_requests.Dequeue(); | ||
195 | } | ||
196 | if (req == null) | ||
197 | Thread.Sleep(100); | ||
198 | else | ||
199 | { | 193 | { |
200 | //PollServiceHttpRequest req = m_requests.Dequeue(5000); | 194 | try |
201 | //m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString())); | ||
202 | |||
203 | if (req != null) | ||
204 | { | 195 | { |
205 | try | 196 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) |
206 | { | 197 | { |
207 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 198 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); |
208 | { | ||
209 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
210 | 199 | ||
211 | if (responsedata == null) | 200 | if (responsedata == null) |
212 | continue; | 201 | continue; |
213 | 202 | ||
214 | if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue | 203 | if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue |
204 | { | ||
205 | try | ||
206 | { | ||
207 | req.DoHTTPGruntWork(m_server, responsedata); | ||
208 | } | ||
209 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | ||
210 | { | ||
211 | // Ignore it, no need to reply | ||
212 | } | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | m_threadPool.QueueWorkItem(x => | ||
215 | { | 217 | { |
216 | try | 218 | try |
217 | { | 219 | { |
@@ -221,41 +223,27 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
221 | { | 223 | { |
222 | // Ignore it, no need to reply | 224 | // Ignore it, no need to reply |
223 | } | 225 | } |
224 | } | ||
225 | else | ||
226 | { | ||
227 | m_threadPool.QueueWorkItem(x => | ||
228 | { | ||
229 | try | ||
230 | { | ||
231 | req.DoHTTPGruntWork(m_server, responsedata); | ||
232 | } | ||
233 | catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream | ||
234 | { | ||
235 | // Ignore it, no need to reply | ||
236 | } | ||
237 | 226 | ||
238 | return null; | 227 | return null; |
239 | }, null); | 228 | }, null); |
240 | } | 229 | } |
230 | } | ||
231 | else | ||
232 | { | ||
233 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
234 | { | ||
235 | req.DoHTTPGruntWork( | ||
236 | m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
241 | } | 237 | } |
242 | else | 238 | else |
243 | { | 239 | { |
244 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 240 | ReQueueEvent(req); |
245 | { | ||
246 | req.DoHTTPGruntWork( | ||
247 | m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | ReQueueEvent(req); | ||
252 | } | ||
253 | } | 241 | } |
254 | } | 242 | } |
255 | catch (Exception e) | 243 | } |
256 | { | 244 | catch (Exception e) |
257 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 245 | { |
258 | } | 246 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
259 | } | 247 | } |
260 | } | 248 | } |
261 | } | 249 | } |