aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs36
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs14
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs289
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs16
-rw-r--r--OpenSim/Framework/Servers/VersionInfo.cs6
6 files changed, 342 insertions, 21 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 7a5c16d..cf19002 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -308,7 +308,7 @@ namespace OpenSim.Framework.Servers
308 308
309 EnhanceVersionInformation(); 309 EnhanceVersionInformation();
310 310
311 m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine); 311 m_log.Info("[STARTUP]: Careminster version: " + m_version + Environment.NewLine);
312 // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and 312 // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
313 // the clr version number doesn't match the project version number under Mono. 313 // the clr version number doesn't match the project version number under Mono.
314 //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine); 314 //m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine);
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index f57ea76..e45cb89 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1448,10 +1448,34 @@ namespace OpenSim.Framework.Servers.HttpServer
1448 1448
1449 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1449 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1450 { 1450 {
1451 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 1451 int responsecode;
1452 int responsecode = (int)responsedata["int_response_code"]; 1452 string responseString;
1453 string responseString = (string)responsedata["str_response_string"]; 1453 string contentType;
1454 string contentType = (string)responsedata["content_type"]; 1454
1455 if (responsedata == null)
1456 {
1457 responsecode = 500;
1458 responseString = "No response could be obtained";
1459 contentType = "text/plain";
1460 responsedata = new Hashtable();
1461 }
1462 else
1463 {
1464 try
1465 {
1466 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
1467 responsecode = (int)responsedata["int_response_code"];
1468 responseString = (string)responsedata["str_response_string"];
1469 contentType = (string)responsedata["content_type"];
1470 }
1471 catch
1472 {
1473 responsecode = 500;
1474 responseString = "No response could be obtained";
1475 contentType = "text/plain";
1476 responsedata = new Hashtable();
1477 }
1478 }
1455 1479
1456 if (responsedata.ContainsKey("error_status_text")) 1480 if (responsedata.ContainsKey("error_status_text"))
1457 { 1481 {
@@ -1628,7 +1652,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1628 1652
1629 public void httpServerException(object source, Exception exception) 1653 public void httpServerException(object source, Exception exception)
1630 { 1654 {
1631 m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); 1655 if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException"))
1656 return;
1657 m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1632 /* 1658 /*
1633 if (HTTPDRunning)// && NotSocketErrors > 5) 1659 if (HTTPDRunning)// && NotSocketErrors > 5)
1634 { 1660 {
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index 3089351..bb43cd2 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -45,17 +45,27 @@ namespace OpenSim.Framework.Servers.HttpServer
45 public NoEventsMethod NoEvents; 45 public NoEventsMethod NoEvents;
46 public RequestMethod Request; 46 public RequestMethod Request;
47 public UUID Id; 47 public UUID Id;
48 public int TimeOutms;
49 public EventType Type;
50
51 public enum EventType : int
52 {
53 Normal = 0,
54 LslHttp = 1
55 }
48 56
49 public PollServiceEventArgs( 57 public PollServiceEventArgs(
50 RequestMethod pRequest, 58 RequestMethod pRequest,
51 HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, 59 HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,
52 UUID pId) 60 UUID pId, int pTimeOutms)
53 { 61 {
54 Request = pRequest; 62 Request = pRequest;
55 HasEvents = pHasEvents; 63 HasEvents = pHasEvents;
56 GetEvents = pGetEvents; 64 GetEvents = pGetEvents;
57 NoEvents = pNoEvents; 65 NoEvents = pNoEvents;
58 Id = pId; 66 Id = pId;
67 TimeOutms = pTimeOutms;
68 Type = EventType.Normal;
59 } 69 }
60 } 70 }
61} \ No newline at end of file 71}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 8d50151..a385110 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -34,14 +34,18 @@ using HttpServer;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Monitoring; 35using OpenSim.Framework.Monitoring;
36 36
37
38/*
37namespace OpenSim.Framework.Servers.HttpServer 39namespace OpenSim.Framework.Servers.HttpServer
38{ 40{
41
39 public class PollServiceRequestManager 42 public class PollServiceRequestManager
40 { 43 {
41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 45
43 private readonly BaseHttpServer m_server; 46 private readonly BaseHttpServer m_server;
44 private static Queue m_requests = Queue.Synchronized(new Queue()); 47 private static Queue m_requests = Queue.Synchronized(new Queue());
48 private static ManualResetEvent m_ev = new ManualResetEvent(false);
45 private uint m_WorkerThreadCount = 0; 49 private uint m_WorkerThreadCount = 0;
46 private Thread[] m_workerThreads; 50 private Thread[] m_workerThreads;
47 private PollServiceWorkerThread[] m_PollServiceWorkerThreads; 51 private PollServiceWorkerThread[] m_PollServiceWorkerThreads;
@@ -67,7 +71,6 @@ namespace OpenSim.Framework.Servers.HttpServer
67 ThreadPriority.Normal, 71 ThreadPriority.Normal,
68 false, 72 false,
69 true, 73 true,
70 null,
71 int.MaxValue); 74 int.MaxValue);
72 } 75 }
73 76
@@ -77,7 +80,6 @@ namespace OpenSim.Framework.Servers.HttpServer
77 ThreadPriority.Normal, 80 ThreadPriority.Normal,
78 false, 81 false,
79 true, 82 true,
80 null,
81 1000 * 60 * 10); 83 1000 * 60 * 10);
82 } 84 }
83 85
@@ -91,15 +93,17 @@ namespace OpenSim.Framework.Servers.HttpServer
91 { 93 {
92 lock (m_requests) 94 lock (m_requests)
93 m_requests.Enqueue(req); 95 m_requests.Enqueue(req);
96 m_ev.Set();
94 } 97 }
95 98
96 public void ThreadStart() 99 public void ThreadStart()
97 { 100 {
98 while (m_running) 101 while (m_running)
99 { 102 {
103 m_ev.WaitOne(1000);
104 m_ev.Reset();
100 Watchdog.UpdateThread(); 105 Watchdog.UpdateThread();
101 ProcessQueuedRequests(); 106 ProcessQueuedRequests();
102 Thread.Sleep(1000);
103 } 107 }
104 } 108 }
105 109
@@ -141,8 +145,9 @@ namespace OpenSim.Framework.Servers.HttpServer
141 foreach (object o in m_requests) 145 foreach (object o in m_requests)
142 { 146 {
143 PollServiceHttpRequest req = (PollServiceHttpRequest) o; 147 PollServiceHttpRequest req = (PollServiceHttpRequest) o;
144 PollServiceWorkerThread.DoHTTPGruntWork( 148 m_server.DoHTTPGruntWork(
145 m_server, req, req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); 149 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
150 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
146 } 151 }
147 152
148 m_requests.Clear(); 153 m_requests.Clear();
@@ -151,8 +156,278 @@ namespace OpenSim.Framework.Servers.HttpServer
151 { 156 {
152 t.Abort(); 157 t.Abort();
153 } 158 }
154
155 m_running = false; 159 m_running = false;
156 } 160 }
157 } 161 }
158} \ No newline at end of file 162}
163 */
164
165using System.IO;
166using System.Text;
167using System.Collections.Generic;
168
169namespace OpenSim.Framework.Servers.HttpServer
170{
171 public class PollServiceRequestManager
172 {
173 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
174
175 private readonly BaseHttpServer m_server;
176
177 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
178 private static Queue<PollServiceHttpRequest> m_slowRequests = new Queue<PollServiceHttpRequest>();
179 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>();
180
181 private uint m_WorkerThreadCount = 0;
182 private Thread[] m_workerThreads;
183 private Thread m_retrysThread;
184
185 private bool m_running = true;
186 private int slowCount = 0;
187
188// private int m_timeout = 1000; // increase timeout 250; now use the event one
189
190 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
191 {
192 m_server = pSrv;
193 m_WorkerThreadCount = pWorkerThreadCount;
194 m_workerThreads = new Thread[m_WorkerThreadCount];
195
196 //startup worker threads
197 for (uint i = 0; i < m_WorkerThreadCount; i++)
198 {
199 m_workerThreads[i]
200 = Watchdog.StartThread(
201 PoolWorkerJob,
202 String.Format("PollServiceWorkerThread{0}", i),
203 ThreadPriority.Normal,
204 false,
205 true,
206 null,
207 int.MaxValue);
208 }
209
210 m_retrysThread = Watchdog.StartThread(
211 this.CheckRetries,
212 "PollServiceWatcherThread",
213 ThreadPriority.Normal,
214 false,
215 true,
216 null,
217 1000 * 60 * 10);
218 }
219
220
221 private void ReQueueEvent(PollServiceHttpRequest req)
222 {
223 if (m_running)
224 {
225 lock (m_retryRequests)
226 m_retryRequests.Enqueue(req);
227 }
228 }
229
230 public void Enqueue(PollServiceHttpRequest req)
231 {
232 if (m_running)
233 {
234 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp)
235 {
236 m_requests.Enqueue(req);
237 }
238 else
239 {
240 lock (m_slowRequests)
241 m_slowRequests.Enqueue(req);
242 }
243 }
244 }
245
246 private void CheckRetries()
247 {
248 while (m_running)
249 {
250 Thread.Sleep(100); // let the world move .. back to faster rate
251 Watchdog.UpdateThread();
252 lock (m_retryRequests)
253 {
254 while (m_retryRequests.Count > 0 && m_running)
255 m_requests.Enqueue(m_retryRequests.Dequeue());
256 }
257 slowCount++;
258 if (slowCount >= 10)
259 {
260 slowCount = 0;
261
262 lock (m_slowRequests)
263 {
264 while (m_slowRequests.Count > 0 && m_running)
265 m_requests.Enqueue(m_slowRequests.Dequeue());
266 }
267 }
268 }
269 }
270
271 ~PollServiceRequestManager()
272 {
273 m_running = false;
274// m_timeout = -10000; // cause all to expire
275 Thread.Sleep(1000); // let the world move
276
277 foreach (Thread t in m_workerThreads)
278 {
279 try
280 {
281 t.Abort();
282 }
283 catch
284 {
285 }
286 }
287
288 try
289 {
290 foreach (PollServiceHttpRequest req in m_retryRequests)
291 {
292 DoHTTPGruntWork(m_server,req,
293 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
294 }
295 }
296 catch
297 {
298 }
299
300 PollServiceHttpRequest wreq;
301 m_retryRequests.Clear();
302
303 lock (m_slowRequests)
304 {
305 while (m_slowRequests.Count > 0 && m_running)
306 m_requests.Enqueue(m_slowRequests.Dequeue());
307 }
308
309 while (m_requests.Count() > 0)
310 {
311 try
312 {
313 wreq = m_requests.Dequeue(0);
314 DoHTTPGruntWork(m_server,wreq,
315 wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id));
316 }
317 catch
318 {
319 }
320 }
321
322 m_requests.Clear();
323 }
324
325 // work threads
326
327 private void PoolWorkerJob()
328 {
329 PollServiceHttpRequest req;
330 StreamReader str;
331
332// while (true)
333 while (m_running)
334 {
335 req = m_requests.Dequeue(5000);
336
337 Watchdog.UpdateThread();
338 if (req != null)
339 {
340 try
341 {
342 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
343 {
344 try
345 {
346 str = new StreamReader(req.Request.Body);
347 }
348 catch (System.ArgumentException)
349 {
350 // Stream was not readable means a child agent
351 // was closed due to logout, leaving the
352 // Event Queue request orphaned.
353 continue;
354 }
355
356 try
357 {
358 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
359 DoHTTPGruntWork(m_server, req, responsedata);
360 }
361 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
362 {
363 // Ignore it, no need to reply
364 }
365
366 str.Close();
367
368 }
369 else
370 {
371// if ((Environment.TickCount - req.RequestTime) > m_timeout)
372
373 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
374 {
375 DoHTTPGruntWork(m_server, req,
376 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
377 }
378 else
379 {
380 ReQueueEvent(req);
381 }
382 }
383 }
384 catch (Exception e)
385 {
386 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
387 }
388 }
389 }
390 }
391
392 // DoHTTPGruntWork changed, not sending response
393 // do the same work around as core
394
395 internal static void DoHTTPGruntWork(BaseHttpServer server, PollServiceHttpRequest req, Hashtable responsedata)
396 {
397 OSHttpResponse response
398 = new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext);
399
400 byte[] buffer = server.DoHTTPGruntWork(responsedata, response);
401
402 response.SendChunked = false;
403 response.ContentLength64 = buffer.Length;
404 response.ContentEncoding = Encoding.UTF8;
405
406 try
407 {
408 response.OutputStream.Write(buffer, 0, buffer.Length);
409 }
410 catch (Exception ex)
411 {
412 m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex));
413 }
414 finally
415 {
416 //response.OutputStream.Close();
417 try
418 {
419 response.OutputStream.Flush();
420 response.Send();
421
422 //if (!response.KeepAlive && response.ReuseContext)
423 // response.FreeContext();
424 }
425 catch (Exception e)
426 {
427 m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e));
428 }
429 }
430 }
431 }
432}
433
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
index 5adbcd1..1c529b6 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
@@ -25,6 +25,8 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28/* Ubit work moved to PollServiceRequestManager
29
28using System; 30using System;
29using System.Collections; 31using System.Collections;
30using System.Collections.Generic; 32using System.Collections.Generic;
@@ -90,8 +92,15 @@ namespace OpenSim.Framework.Servers.HttpServer
90 continue; 92 continue;
91 } 93 }
92 94
93 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); 95 try
94 DoHTTPGruntWork(m_server, req, responsedata); 96 {
97 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
98 DoHTTPGruntWork(m_server, req, responsedata);
99 }
100 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
101 {
102 // Ignore it, no need to reply
103 }
95 } 104 }
96 else 105 else
97 { 106 {
@@ -162,4 +171,5 @@ namespace OpenSim.Framework.Servers.HttpServer
162 } 171 }
163 } 172 }
164 } 173 }
165} \ No newline at end of file 174}
175*/ \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 5f01788..016a174 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,11 +29,11 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 private const string VERSION_NUMBER = "0.7.4"; 32 private const string VERSION_NUMBER = "0.7.4CM";
33 private const Flavour VERSION_FLAVOUR = Flavour.Dev; 33 private const Flavour VERSION_FLAVOUR = Flavour.Dev;
34 34
35 public enum Flavour 35 public enum Flavour
36 { 36 {
37 Unknown, 37 Unknown,
38 Dev, 38 Dev,
39 RC1, 39 RC1,
@@ -50,7 +50,7 @@ namespace OpenSim
50 50
51 public static string GetVersionString(string versionNumber, Flavour flavour) 51 public static string GetVersionString(string versionNumber, Flavour flavour)
52 { 52 {
53 string versionString = "OpenSim " + versionNumber + " " + flavour; 53 string versionString = "Careminster " + versionNumber + " " + flavour;
54 return versionString.PadRight(VERSIONINFO_VERSION_LENGTH); 54 return versionString.PadRight(VERSIONINFO_VERSION_LENGTH);
55 } 55 }
56 56