aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/BlockingQueue.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs79
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs8
4 files changed, 52 insertions, 41 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index e607e64..aef1192 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Framework
76 { 76 {
77 lock (m_queueSync) 77 lock (m_queueSync)
78 { 78 {
79 while (m_queue.Count < 1 && m_pqueue.Count < 1) 79 if (m_queue.Count < 1 && m_pqueue.Count < 1)
80 { 80 {
81 Monitor.Wait(m_queueSync, msTimeout); 81 Monitor.Wait(m_queueSync, msTimeout);
82 } 82 }
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index 9477100..020bfd5 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Framework.Servers.HttpServer
50 50
51 public enum EventType : int 51 public enum EventType : int
52 { 52 {
53 LongPoll = 0, 53 Normal = 0,
54 LslHttp = 1, 54 LslHttp = 1,
55 Inventory = 2 55 Inventory = 2
56 } 56 }
@@ -80,7 +80,7 @@ namespace OpenSim.Framework.Servers.HttpServer
80 NoEvents = pNoEvents; 80 NoEvents = pNoEvents;
81 Id = pId; 81 Id = pId;
82 TimeOutms = pTimeOutms; 82 TimeOutms = pTimeOutms;
83 Type = EventType.LongPoll; 83 Type = EventType.Normal;
84 } 84 }
85 } 85 }
86} 86}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 4cb551c..1b9010a 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -47,11 +47,12 @@ namespace OpenSim.Framework.Servers.HttpServer
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 BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
50 private static Queue<PollServiceHttpRequest> m_longPollRequests = new Queue<PollServiceHttpRequest>(); 50 private static Queue<PollServiceHttpRequest> m_slowRequests = new Queue<PollServiceHttpRequest>();
51 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>();
51 52
52 private uint m_WorkerThreadCount = 0; 53 private uint m_WorkerThreadCount = 0;
53 private Thread[] m_workerThreads; 54 private Thread[] m_workerThreads;
54 private Thread m_longPollThread; 55 private Thread m_retrysThread;
55 56
56 private bool m_running = true; 57 private bool m_running = true;
57 private int slowCount = 0; 58 private int slowCount = 0;
@@ -83,9 +84,9 @@ namespace OpenSim.Framework.Servers.HttpServer
83 int.MaxValue); 84 int.MaxValue);
84 } 85 }
85 86
86 m_longPollThread = Watchdog.StartThread( 87 m_retrysThread = Watchdog.StartThread(
87 this.CheckLongPollThreads, 88 this.CheckRetries,
88 string.Format("LongPollServiceWatcherThread:{0}", m_server.Port), 89 string.Format("PollServiceWatcherThread:{0}", m_server.Port),
89 ThreadPriority.Normal, 90 ThreadPriority.Normal,
90 false, 91 false,
91 true, 92 true,
@@ -96,47 +97,48 @@ namespace OpenSim.Framework.Servers.HttpServer
96 private void ReQueueEvent(PollServiceHttpRequest req) 97 private void ReQueueEvent(PollServiceHttpRequest req)
97 { 98 {
98 if (m_running) 99 if (m_running)
99 m_requests.Enqueue(req); 100 {
101 lock (m_retryRequests)
102 m_retryRequests.Enqueue(req);
103 }
100 } 104 }
101 105
102 public void Enqueue(PollServiceHttpRequest req) 106 public void Enqueue(PollServiceHttpRequest req)
103 { 107 {
104 if (m_running) 108 if (m_running)
105 { 109 {
106 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) 110 if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.Normal)
107 { 111 {
108 lock (m_longPollRequests) 112 m_requests.Enqueue(req);
109 m_longPollRequests.Enqueue(req);
110 } 113 }
111 else 114 else
112 m_requests.Enqueue(req); 115 {
116 lock (m_slowRequests)
117 m_slowRequests.Enqueue(req);
118 }
113 } 119 }
114 } 120 }
115 121
116 private void CheckLongPollThreads() 122 private void CheckRetries()
117 { 123 {
118 // The only purpose of this thread is to check the EQs for events.
119 // If there are events, that thread will be placed in the "ready-to-serve" queue, m_requests.
120 // If there are no events, that thread will be back to its "waiting" queue, m_longPollRequests.
121 // All other types of tasks (Inventory handlers) don't have the long-poll nature,
122 // so if they aren't ready to be served by a worker thread (no events), they are placed
123 // directly back in the "ready-to-serve" queue by the worker thread.
124 while (m_running) 124 while (m_running)
125 { 125 {
126 Thread.Sleep(1000); 126 Thread.Sleep(100); // let the world move .. back to faster rate
127 Watchdog.UpdateThread(); 127 Watchdog.UpdateThread();
128 128 lock (m_retryRequests)
129 PollServiceHttpRequest req; 129 {
130 lock (m_longPollRequests) 130 while (m_retryRequests.Count > 0 && m_running)
131 m_requests.Enqueue(m_retryRequests.Dequeue());
132 }
133 slowCount++;
134 if (slowCount >= 10)
131 { 135 {
132 while (m_longPollRequests.Count > 0 && m_running) 136 slowCount = 0;
137
138 lock (m_slowRequests)
133 { 139 {
134 req = m_longPollRequests.Dequeue(); 140 while (m_slowRequests.Count > 0 && m_running)
135 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ 141 m_requests.Enqueue(m_slowRequests.Dequeue());
136 (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout
137 m_requests.Enqueue(req);
138 else
139 m_longPollRequests.Enqueue(req);
140 } 142 }
141 } 143 }
142 } 144 }
@@ -151,12 +153,24 @@ namespace OpenSim.Framework.Servers.HttpServer
151 foreach (Thread t in m_workerThreads) 153 foreach (Thread t in m_workerThreads)
152 Watchdog.AbortThread(t.ManagedThreadId); 154 Watchdog.AbortThread(t.ManagedThreadId);
153 155
156 try
157 {
158 foreach (PollServiceHttpRequest req in m_retryRequests)
159 {
160 req.DoHTTPGruntWork(m_server, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
161 }
162 }
163 catch
164 {
165 }
166
154 PollServiceHttpRequest wreq; 167 PollServiceHttpRequest wreq;
168 m_retryRequests.Clear();
155 169
156 lock (m_longPollRequests) 170 lock (m_slowRequests)
157 { 171 {
158 while (m_longPollRequests.Count > 0 && m_running) 172 while (m_slowRequests.Count > 0 && m_running)
159 m_requests.Enqueue(m_longPollRequests.Dequeue()); 173 m_requests.Enqueue(m_slowRequests.Dequeue());
160 } 174 }
161 175
162 while (m_requests.Count() > 0) 176 while (m_requests.Count() > 0)
@@ -182,7 +196,6 @@ namespace OpenSim.Framework.Servers.HttpServer
182 while (m_running) 196 while (m_running)
183 { 197 {
184 PollServiceHttpRequest req = m_requests.Dequeue(5000); 198 PollServiceHttpRequest req = m_requests.Dequeue(5000);
185 //m_log.WarnFormat("[YYY]: Dequeued {0}", (req == null ? "null" : req.PollServiceArgs.Type.ToString()));
186 199
187 Watchdog.UpdateThread(); 200 Watchdog.UpdateThread();
188 if (req != null) 201 if (req != null)
@@ -196,7 +209,7 @@ namespace OpenSim.Framework.Servers.HttpServer
196 if (responsedata == null) 209 if (responsedata == null)
197 continue; 210 continue;
198 211
199 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue 212 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal) // This is the event queue
200 { 213 {
201 try 214 try
202 { 215 {
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index f0445ff..1835a72 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -364,7 +364,8 @@ namespace OpenSim.Region.ClientStack.Linden
364 364
365 caps.RegisterPollHandler( 365 caps.RegisterPollHandler(
366 "EventQueueGet", 366 "EventQueueGet",
367 new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); 367 new PollServiceEventArgs(
368 null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000));
368 369
369 Random rnd = new Random(Environment.TickCount); 370 Random rnd = new Random(Environment.TickCount);
370 lock (m_ids) 371 lock (m_ids)
@@ -382,10 +383,7 @@ namespace OpenSim.Region.ClientStack.Linden
382 Queue<OSD> queue = GetQueue(agentID); 383 Queue<OSD> queue = GetQueue(agentID);
383 if (queue != null) 384 if (queue != null)
384 lock (queue) 385 lock (queue)
385 {
386 //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count);
387 return queue.Count > 0; 386 return queue.Count > 0;
388 }
389 387
390 return false; 388 return false;
391 } 389 }
@@ -408,7 +406,7 @@ namespace OpenSim.Region.ClientStack.Linden
408 public Hashtable GetEvents(UUID requestID, UUID pAgentId) 406 public Hashtable GetEvents(UUID requestID, UUID pAgentId)
409 { 407 {
410 if (DebugLevel >= 2) 408 if (DebugLevel >= 2)
411 m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); 409 m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName);
412 410
413 Queue<OSD> queue = TryGetQueue(pAgentId); 411 Queue<OSD> queue = TryGetQueue(pAgentId);
414 OSD element; 412 OSD element;