diff options
author | Diva Canto | 2013-07-17 14:36:55 -0700 |
---|---|---|
committer | Diva Canto | 2013-07-17 14:36:55 -0700 |
commit | 5232ab0496eb4fe6903a0fd328974ac69df29ad8 (patch) | |
tree | 0c36bf127d0638f44d4a3a7f890f9c37d594dd97 /OpenSim/Framework | |
parent | Now trying DoubleQueue instead of BlockingQueue for the PollServiceRequestMan... (diff) | |
download | opensim-SC_OLD-5232ab0496eb4fe6903a0fd328974ac69df29ad8.zip opensim-SC_OLD-5232ab0496eb4fe6903a0fd328974ac69df29ad8.tar.gz opensim-SC_OLD-5232ab0496eb4fe6903a0fd328974ac69df29ad8.tar.bz2 opensim-SC_OLD-5232ab0496eb4fe6903a0fd328974ac69df29ad8.tar.xz |
This is a completely unreasonable thing to do, effectively defying the purpose of BlockingQueues. Trying this, to see the effect on CPU.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 92 |
1 files changed, 52 insertions, 40 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index bad28e4..b8f5743 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 DoubleQueue<PollServiceHttpRequest> m_requests = new DoubleQueue<PollServiceHttpRequest>(); | 49 | private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<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,35 +185,33 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
185 | { | 185 | { |
186 | while (m_running) | 186 | while (m_running) |
187 | { | 187 | { |
188 | PollServiceHttpRequest req = m_requests.Dequeue(5000); | ||
189 | //m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString())); | ||
190 | |||
191 | Watchdog.UpdateThread(); | 188 | Watchdog.UpdateThread(); |
192 | if (req != null) | 189 | |
190 | PollServiceHttpRequest req = null; | ||
191 | lock (m_requests) | ||
192 | { | ||
193 | if (m_requests.Count() > 0) | ||
194 | req = m_requests.Dequeue(); | ||
195 | } | ||
196 | if (req == null) | ||
197 | Thread.Sleep(100); | ||
198 | else | ||
193 | { | 199 | { |
194 | try | 200 | //PollServiceHttpRequest req = m_requests.Dequeue(5000); |
201 | //m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString())); | ||
202 | |||
203 | if (req != null) | ||
195 | { | 204 | { |
196 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 205 | try |
197 | { | 206 | { |
198 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 207 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) |
208 | { | ||
209 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
199 | 210 | ||
200 | if (responsedata == null) | 211 | if (responsedata == null) |
201 | continue; | 212 | continue; |
202 | 213 | ||
203 | if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue | 214 | 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 => | ||
217 | { | 215 | { |
218 | try | 216 | try |
219 | { | 217 | { |
@@ -223,27 +221,41 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
223 | { | 221 | { |
224 | // Ignore it, no need to reply | 222 | // Ignore it, no need to reply |
225 | } | 223 | } |
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 | } | ||
226 | 237 | ||
227 | return null; | 238 | return null; |
228 | }, null); | 239 | }, null); |
229 | } | 240 | } |
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)); | ||
237 | } | 241 | } |
238 | else | 242 | else |
239 | { | 243 | { |
240 | ReQueueEvent(req); | 244 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) |
245 | { | ||
246 | req.DoHTTPGruntWork( | ||
247 | m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | ReQueueEvent(req); | ||
252 | } | ||
241 | } | 253 | } |
242 | } | 254 | } |
243 | } | 255 | catch (Exception e) |
244 | catch (Exception e) | 256 | { |
245 | { | 257 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
246 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 258 | } |
247 | } | 259 | } |
248 | } | 260 | } |
249 | } | 261 | } |