aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-08-18 21:03:34 +0100
committerUbitUmarov2015-08-18 21:03:34 +0100
commit2cac56340a079fad8a16736778b6ebef78fb6d56 (patch)
tree90cb9963be59cf802d97961abff1dfddaea2a3bd /OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
parentTrack selected objects per client (diff)
downloadopensim-SC_OLD-2cac56340a079fad8a16736778b6ebef78fb6d56.zip
opensim-SC_OLD-2cac56340a079fad8a16736778b6ebef78fb6d56.tar.gz
opensim-SC_OLD-2cac56340a079fad8a16736778b6ebef78fb6d56.tar.bz2
opensim-SC_OLD-2cac56340a079fad8a16736778b6ebef78fb6d56.tar.xz
try to serialize http requests from same connection, so they are processed
in order. ( next commits will be about necessary keepAlive changes needed)
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index e75b705..2c5c41d 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -46,6 +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 Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext;
49 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>(); 50 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
50 private static Queue<PollServiceHttpRequest> m_slowRequests = new Queue<PollServiceHttpRequest>(); 51 private static Queue<PollServiceHttpRequest> m_slowRequests = new Queue<PollServiceHttpRequest>();
51 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>(); 52 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>();
@@ -65,6 +66,9 @@ namespace OpenSim.Framework.Servers.HttpServer
65 m_WorkerThreadCount = pWorkerThreadCount; 66 m_WorkerThreadCount = pWorkerThreadCount;
66 m_workerThreads = new Thread[m_WorkerThreadCount]; 67 m_workerThreads = new Thread[m_WorkerThreadCount];
67 68
69 PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer();
70 m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp);
71
68 STPStartInfo startInfo = new STPStartInfo(); 72 STPStartInfo startInfo = new STPStartInfo();
69 startInfo.IdleTimeout = 30000; 73 startInfo.IdleTimeout = 30000;
70 startInfo.MaxWorkerThreads = 15; 74 startInfo.MaxWorkerThreads = 15;
@@ -114,6 +118,45 @@ namespace OpenSim.Framework.Servers.HttpServer
114 118
115 public void Enqueue(PollServiceHttpRequest req) 119 public void Enqueue(PollServiceHttpRequest req)
116 { 120 {
121 lock (m_bycontext)
122 {
123 Queue<PollServiceHttpRequest> ctxQeueue;
124 if (m_bycontext.TryGetValue(req, out ctxQeueue))
125 {
126 ctxQeueue.Enqueue(req);
127 }
128 else
129 {
130 ctxQeueue = new Queue<PollServiceHttpRequest>();
131 m_bycontext[req] = ctxQeueue;
132 EnqueueInt(req);
133 }
134 }
135 }
136
137 public void byContextDequeue(PollServiceHttpRequest req)
138 {
139 Queue<PollServiceHttpRequest> ctxQeueue;
140 lock (m_bycontext)
141 {
142 if (m_bycontext.TryGetValue(req, out ctxQeueue))
143 {
144 if (ctxQeueue.Count > 0)
145 {
146 PollServiceHttpRequest newreq = ctxQeueue.Dequeue();
147 EnqueueInt(newreq);
148 }
149 else
150 {
151 m_bycontext.Remove(req);
152 }
153 }
154 }
155 }
156
157
158 public void EnqueueInt(PollServiceHttpRequest req)
159 {
117 if (m_running) 160 if (m_running)
118 { 161 {
119 if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.LongPoll) 162 if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.LongPoll)
@@ -220,6 +263,7 @@ namespace OpenSim.Framework.Servers.HttpServer
220 try 263 try
221 { 264 {
222 req.DoHTTPGruntWork(m_server, responsedata); 265 req.DoHTTPGruntWork(m_server, responsedata);
266 byContextDequeue(req);
223 } 267 }
224 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream 268 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
225 { 269 {
@@ -233,6 +277,7 @@ namespace OpenSim.Framework.Servers.HttpServer
233 try 277 try
234 { 278 {
235 req.DoHTTPGruntWork(m_server, responsedata); 279 req.DoHTTPGruntWork(m_server, responsedata);
280 byContextDequeue(req);
236 } 281 }
237 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream 282 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
238 { 283 {
@@ -249,6 +294,7 @@ namespace OpenSim.Framework.Servers.HttpServer
249 { 294 {
250 req.DoHTTPGruntWork(m_server, 295 req.DoHTTPGruntWork(m_server,
251 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); 296 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
297 byContextDequeue(req);
252 } 298 }
253 else 299 else
254 { 300 {