aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorUbitUmarov2018-01-24 03:12:56 +0000
committerUbitUmarov2018-01-24 03:12:56 +0000
commitc87585ad96e11397841b8c49b968e11f7c276e21 (patch)
treecaf7c5802b2be7fa1b8d2681116d93ae5f052c59 /OpenSim/Framework
parentreduce max keepalime time to 60s (diff)
downloadopensim-SC-c87585ad96e11397841b8c49b968e11f7c276e21.zip
opensim-SC-c87585ad96e11397841b8c49b968e11f7c276e21.tar.gz
opensim-SC-c87585ad96e11397841b8c49b968e11f7c276e21.tar.bz2
opensim-SC-c87585ad96e11397841b8c49b968e11f7c276e21.tar.xz
simplify http bycontext key
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs18
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs27
2 files changed, 15 insertions, 30 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
index 8ab5808..d5c25b9 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
@@ -130,27 +130,9 @@ namespace OpenSim.Framework.Servers.HttpServer
130 response.OutputStream.Flush(); 130 response.OutputStream.Flush();
131 response.Send(); 131 response.Send();
132 } 132 }
133// catch (Exception e)
134 catch 133 catch
135 { 134 {
136 } 135 }
137 } 136 }
138 } 137 }
139
140 class PollServiceHttpRequestComparer : IEqualityComparer<PollServiceHttpRequest>
141 {
142 public bool Equals(PollServiceHttpRequest b1, PollServiceHttpRequest b2)
143 {
144 if (b1.contextHash != b2.contextHash)
145 return false;
146// bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext);
147// return b;
148 return true;
149 }
150
151 public int GetHashCode(PollServiceHttpRequest b2)
152 {
153 return (int)b2.contextHash;
154 }
155 }
156} \ No newline at end of file 138} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index db445fa..a2f6a11 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework.Servers.HttpServer
43 43
44 private readonly BaseHttpServer m_server; 44 private readonly BaseHttpServer m_server;
45 45
46 private Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>> m_bycontext; 46 private Dictionary<int, Queue<PollServiceHttpRequest>> m_bycontext;
47 private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>(); 47 private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>();
48 private static ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>(); 48 private static ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>();
49 49
@@ -62,8 +62,7 @@ namespace OpenSim.Framework.Servers.HttpServer
62 m_WorkerThreadCount = pWorkerThreadCount; 62 m_WorkerThreadCount = pWorkerThreadCount;
63 m_workerThreads = new Thread[m_WorkerThreadCount]; 63 m_workerThreads = new Thread[m_WorkerThreadCount];
64 64
65 PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer(); 65 m_bycontext = new Dictionary<int, Queue<PollServiceHttpRequest>>(256);
66 m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp);
67 66
68 STPStartInfo startInfo = new STPStartInfo(); 67 STPStartInfo startInfo = new STPStartInfo();
69 startInfo.IdleTimeout = 30000; 68 startInfo.IdleTimeout = 30000;
@@ -102,8 +101,6 @@ namespace OpenSim.Framework.Servers.HttpServer
102 true, 101 true,
103 null, 102 null,
104 1000 * 60 * 10); 103 1000 * 60 * 10);
105
106
107 } 104 }
108 105
109 private void ReQueueEvent(PollServiceHttpRequest req) 106 private void ReQueueEvent(PollServiceHttpRequest req)
@@ -114,17 +111,18 @@ namespace OpenSim.Framework.Servers.HttpServer
114 111
115 public void Enqueue(PollServiceHttpRequest req) 112 public void Enqueue(PollServiceHttpRequest req)
116 { 113 {
114 Queue<PollServiceHttpRequest> ctxQeueue;
115 int rhash = req.contextHash;
117 lock (m_bycontext) 116 lock (m_bycontext)
118 { 117 {
119 Queue<PollServiceHttpRequest> ctxQeueue; 118 if (m_bycontext.TryGetValue(rhash, out ctxQeueue))
120 if (m_bycontext.TryGetValue(req, out ctxQeueue))
121 { 119 {
122 ctxQeueue.Enqueue(req); 120 ctxQeueue.Enqueue(req);
123 } 121 }
124 else 122 else
125 { 123 {
126 ctxQeueue = new Queue<PollServiceHttpRequest>(); 124 ctxQeueue = new Queue<PollServiceHttpRequest>();
127 m_bycontext[req] = ctxQeueue; 125 m_bycontext[rhash] = ctxQeueue;
128 EnqueueInt(req); 126 EnqueueInt(req);
129 } 127 }
130 } 128 }
@@ -133,9 +131,10 @@ namespace OpenSim.Framework.Servers.HttpServer
133 public void byContextDequeue(PollServiceHttpRequest req) 131 public void byContextDequeue(PollServiceHttpRequest req)
134 { 132 {
135 Queue<PollServiceHttpRequest> ctxQeueue; 133 Queue<PollServiceHttpRequest> ctxQeueue;
134 int rhash = req.contextHash;
136 lock (m_bycontext) 135 lock (m_bycontext)
137 { 136 {
138 if (m_bycontext.TryGetValue(req, out ctxQeueue)) 137 if (m_bycontext.TryGetValue(rhash, out ctxQeueue))
139 { 138 {
140 if (ctxQeueue.Count > 0) 139 if (ctxQeueue.Count > 0)
141 { 140 {
@@ -144,7 +143,7 @@ namespace OpenSim.Framework.Servers.HttpServer
144 } 143 }
145 else 144 else
146 { 145 {
147 m_bycontext.Remove(req); 146 m_bycontext.Remove(rhash);
148 } 147 }
149 } 148 }
150 } 149 }
@@ -153,12 +152,13 @@ namespace OpenSim.Framework.Servers.HttpServer
153 public void DropByContext(PollServiceHttpRequest req) 152 public void DropByContext(PollServiceHttpRequest req)
154 { 153 {
155 Queue<PollServiceHttpRequest> ctxQeueue; 154 Queue<PollServiceHttpRequest> ctxQeueue;
155 int rhash = req.contextHash;
156 lock (m_bycontext) 156 lock (m_bycontext)
157 { 157 {
158 if (m_bycontext.TryGetValue(req, out ctxQeueue)) 158 if (m_bycontext.TryGetValue(rhash, out ctxQeueue))
159 { 159 {
160 ctxQeueue.Clear(); 160 ctxQeueue.Clear();
161 m_bycontext.Remove(req); 161 m_bycontext.Remove(rhash);
162 } 162 }
163 } 163 }
164 } 164 }
@@ -228,6 +228,7 @@ namespace OpenSim.Framework.Servers.HttpServer
228 PollServiceHttpRequest req; 228 PollServiceHttpRequest req;
229 while (m_running) 229 while (m_running)
230 { 230 {
231 req = null;
231 if(!m_requests.TryTake(out req, 4500) || req == null) 232 if(!m_requests.TryTake(out req, 4500) || req == null)
232 { 233 {
233 Watchdog.UpdateThread(); 234 Watchdog.UpdateThread();
@@ -271,6 +272,7 @@ namespace OpenSim.Framework.Servers.HttpServer
271 finally 272 finally
272 { 273 {
273 byContextDequeue(nreq); 274 byContextDequeue(nreq);
275 nreq = null;
274 } 276 }
275 return null; 277 return null;
276 }, null); 278 }, null);
@@ -291,6 +293,7 @@ namespace OpenSim.Framework.Servers.HttpServer
291 finally 293 finally
292 { 294 {
293 byContextDequeue(nreq); 295 byContextDequeue(nreq);
296 nreq = null;
294 } 297 }
295 return null; 298 return null;
296 }, null); 299 }, null);