diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 9115b62..cbdd781 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Concurrent; | ||
31 | using System.Threading; | 30 | using System.Threading; |
32 | using System.Reflection; | 31 | using System.Reflection; |
33 | using log4net; | 32 | using log4net; |
@@ -47,9 +46,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
47 | 46 | ||
48 | private readonly BaseHttpServer m_server; | 47 | private readonly BaseHttpServer m_server; |
49 | 48 | ||
50 | private ConcurrentDictionary <PollServiceHttpRequest,ConcurrentQueue<PollServiceHttpRequest>> m_bycontext; | 49 | private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext; |
51 | private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>(); | 50 | private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); |
52 | private static ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>(); | 51 | private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>(); |
52 | |||
53 | private uint m_WorkerThreadCount = 0; | 53 | private uint m_WorkerThreadCount = 0; |
54 | private Thread[] m_workerThreads; | 54 | private Thread[] m_workerThreads; |
55 | private Thread m_retrysThread; | 55 | private Thread m_retrysThread; |
@@ -66,7 +66,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
66 | m_workerThreads = new Thread[m_WorkerThreadCount]; | 66 | m_workerThreads = new Thread[m_WorkerThreadCount]; |
67 | 67 | ||
68 | PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer(); | 68 | PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer(); |
69 | m_bycontext = new ConcurrentDictionary <PollServiceHttpRequest, ConcurrentQueue<PollServiceHttpRequest>>(preqCp); | 69 | m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp); |
70 | 70 | ||
71 | STPStartInfo startInfo = new STPStartInfo(); | 71 | STPStartInfo startInfo = new STPStartInfo(); |
72 | startInfo.IdleTimeout = 30000; | 72 | startInfo.IdleTimeout = 30000; |
@@ -113,23 +113,23 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
113 | { | 113 | { |
114 | if (m_running) | 114 | if (m_running) |
115 | { | 115 | { |
116 | // lock (m_retryRequests) | 116 | lock (m_retryRequests) |
117 | m_retryRequests.Enqueue(req); | 117 | m_retryRequests.Enqueue(req); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | public void Enqueue(PollServiceHttpRequest req) | 121 | public void Enqueue(PollServiceHttpRequest req) |
122 | { | 122 | { |
123 | // lock (m_bycontext) | 123 | lock (m_bycontext) |
124 | { | 124 | { |
125 | ConcurrentQueue<PollServiceHttpRequest> ctxQeueue; | 125 | Queue<PollServiceHttpRequest> ctxQeueue; |
126 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | 126 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) |
127 | { | 127 | { |
128 | ctxQeueue.Enqueue(req); | 128 | ctxQeueue.Enqueue(req); |
129 | } | 129 | } |
130 | else | 130 | else |
131 | { | 131 | { |
132 | ctxQeueue = new ConcurrentQueue<PollServiceHttpRequest>(); | 132 | ctxQeueue = new Queue<PollServiceHttpRequest>(); |
133 | m_bycontext[req] = ctxQeueue; | 133 | m_bycontext[req] = ctxQeueue; |
134 | EnqueueInt(req); | 134 | EnqueueInt(req); |
135 | } | 135 | } |
@@ -138,20 +138,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
138 | 138 | ||
139 | public void byContextDequeue(PollServiceHttpRequest req) | 139 | public void byContextDequeue(PollServiceHttpRequest req) |
140 | { | 140 | { |
141 | ConcurrentQueue<PollServiceHttpRequest> ctxQeueue; | 141 | Queue<PollServiceHttpRequest> ctxQeueue; |
142 | // lock (m_bycontext) | 142 | lock (m_bycontext) |
143 | { | 143 | { |
144 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | 144 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) |
145 | { | 145 | { |
146 | if (!ctxQeueue.IsEmpty) | 146 | if (ctxQeueue.Count > 0) |
147 | { | 147 | { |
148 | PollServiceHttpRequest newreq; | 148 | PollServiceHttpRequest newreq = ctxQeueue.Dequeue(); |
149 | if(ctxQeueue.TryDequeue(out newreq)) | 149 | EnqueueInt(newreq); |
150 | EnqueueInt(newreq); | ||
151 | } | 150 | } |
152 | else | 151 | else |
153 | { | 152 | { |
154 | m_bycontext.TryRemove(req, out ctxQeueue); | 153 | m_bycontext.Remove(req); |
155 | } | 154 | } |
156 | } | 155 | } |
157 | } | 156 | } |
@@ -159,13 +158,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
159 | 158 | ||
160 | public void DropByContext(PollServiceHttpRequest req) | 159 | public void DropByContext(PollServiceHttpRequest req) |
161 | { | 160 | { |
162 | ConcurrentQueue<PollServiceHttpRequest> ctxQeueue; | 161 | Queue<PollServiceHttpRequest> ctxQeueue; |
163 | lock (m_bycontext) | 162 | lock (m_bycontext) |
164 | { | 163 | { |
165 | if (m_bycontext.ContainsKey(req)) | 164 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) |
166 | { | 165 | { |
167 | // ctxQeueue.Clear(); | 166 | ctxQeueue.Clear(); |
168 | m_bycontext.TryRemove(req, out ctxQeueue); | 167 | m_bycontext.Remove(req); |
169 | } | 168 | } |
170 | } | 169 | } |
171 | } | 170 | } |
@@ -173,21 +172,20 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
173 | public void EnqueueInt(PollServiceHttpRequest req) | 172 | public void EnqueueInt(PollServiceHttpRequest req) |
174 | { | 173 | { |
175 | if (m_running) | 174 | if (m_running) |
176 | m_requests.Add(req); | 175 | m_requests.Enqueue(req); |
177 | } | 176 | } |
178 | 177 | ||
179 | private void CheckRetries() | 178 | private void CheckRetries() |
180 | { | 179 | { |
181 | PollServiceHttpRequest req; | ||
182 | while (m_running) | 180 | while (m_running) |
181 | |||
183 | { | 182 | { |
184 | Thread.Sleep(100); // let the world move .. back to faster rate | 183 | Thread.Sleep(100); // let the world move .. back to faster rate |
185 | Watchdog.UpdateThread(); | 184 | Watchdog.UpdateThread(); |
186 | // lock (m_retryRequests) | 185 | lock (m_retryRequests) |
187 | { | 186 | { |
188 | while (m_retryRequests.Count > 0 && m_running) | 187 | while (m_retryRequests.Count > 0 && m_running) |
189 | if(m_retryRequests.TryDequeue(out req)) | 188 | m_requests.Enqueue(m_retryRequests.Dequeue()); |
190 | m_requests.Add(req); | ||
191 | } | 189 | } |
192 | } | 190 | } |
193 | } | 191 | } |
@@ -205,8 +203,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
205 | 203 | ||
206 | // any entry in m_bycontext should have a active request on the other queues | 204 | // any entry in m_bycontext should have a active request on the other queues |
207 | // so just delete contents to easy GC | 205 | // so just delete contents to easy GC |
208 | // foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values) | 206 | foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values) |
209 | // qu.Clear(); | 207 | qu.Clear(); |
210 | m_bycontext.Clear(); | 208 | m_bycontext.Clear(); |
211 | 209 | ||
212 | try | 210 | try |
@@ -222,13 +220,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
222 | 220 | ||
223 | PollServiceHttpRequest wreq; | 221 | PollServiceHttpRequest wreq; |
224 | 222 | ||
225 | // m_retryRequests.Clear(); | 223 | m_retryRequests.Clear(); |
226 | 224 | ||
227 | while (m_requests.Count > 0) | 225 | while (m_requests.Count() > 0) |
228 | { | 226 | { |
229 | try | 227 | try |
230 | { | 228 | { |
231 | wreq = m_requests.Take(); | 229 | wreq = m_requests.Dequeue(0); |
232 | wreq.DoHTTPstop(m_server); | 230 | wreq.DoHTTPstop(m_server); |
233 | } | 231 | } |
234 | catch | 232 | catch |
@@ -236,7 +234,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
236 | } | 234 | } |
237 | } | 235 | } |
238 | 236 | ||
239 | // m_requests.Clear(); | 237 | m_requests.Clear(); |
240 | } | 238 | } |
241 | 239 | ||
242 | // work threads | 240 | // work threads |
@@ -245,7 +243,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
245 | { | 243 | { |
246 | while (m_running) | 244 | while (m_running) |
247 | { | 245 | { |
248 | PollServiceHttpRequest req = m_requests.Take(); | 246 | PollServiceHttpRequest req = m_requests.Dequeue(4500); |
249 | Watchdog.UpdateThread(); | 247 | Watchdog.UpdateThread(); |
250 | if(req == null) | 248 | if(req == null) |
251 | continue; | 249 | continue; |