diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 97035e3..f4b4156 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -54,7 +54,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); | 55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); |
56 | 56 | ||
57 | |||
58 | /// <summary> | 57 | /// <summary> |
59 | /// This is a pending websocket request before it got an sucessful upgrade response. | 58 | /// This is a pending websocket request before it got an sucessful upgrade response. |
60 | /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to | 59 | /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to |
@@ -81,6 +80,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
81 | /// </remarks> | 80 | /// </remarks> |
82 | public int RequestNumber { get; private set; } | 81 | public int RequestNumber { get; private set; } |
83 | 82 | ||
83 | /// <summary> | ||
84 | /// Statistic for holding number of requests processed. | ||
85 | /// </summary> | ||
86 | private Stat m_requestsProcessedStat; | ||
87 | |||
84 | private volatile int NotSocketErrors = 0; | 88 | private volatile int NotSocketErrors = 0; |
85 | public volatile bool HTTPDRunning = false; | 89 | public volatile bool HTTPDRunning = false; |
86 | 90 | ||
@@ -383,6 +387,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
383 | 387 | ||
384 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) | 388 | if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) |
385 | { | 389 | { |
390 | psEvArgs.RequestsReceived++; | ||
391 | |||
386 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); | 392 | PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request); |
387 | 393 | ||
388 | if (psEvArgs.Request != null) | 394 | if (psEvArgs.Request != null) |
@@ -437,9 +443,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
437 | } | 443 | } |
438 | } | 444 | } |
439 | 445 | ||
440 | public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) | 446 | private void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) |
441 | { | 447 | { |
442 | |||
443 | OSHttpRequest req = new OSHttpRequest(context, request); | 448 | OSHttpRequest req = new OSHttpRequest(context, request); |
444 | WebSocketRequestDelegate dWebSocketRequestDelegate = null; | 449 | WebSocketRequestDelegate dWebSocketRequestDelegate = null; |
445 | lock (m_WebSocketHandlers) | 450 | lock (m_WebSocketHandlers) |
@@ -454,9 +459,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
454 | } | 459 | } |
455 | 460 | ||
456 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); | 461 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); |
457 | 462 | resp.ReuseContext = true; | |
458 | HandleRequest(req, resp); | 463 | HandleRequest(req, resp); |
459 | |||
460 | 464 | ||
461 | // !!!HACK ALERT!!! | 465 | // !!!HACK ALERT!!! |
462 | // There seems to be a bug in the underlying http code that makes subsequent requests | 466 | // There seems to be a bug in the underlying http code that makes subsequent requests |
@@ -687,7 +691,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
687 | 691 | ||
688 | if (buffer != null) | 692 | if (buffer != null) |
689 | { | 693 | { |
690 | if (!response.SendChunked) | 694 | if (!response.SendChunked && response.ContentLength64 <= 0) |
691 | response.ContentLength64 = buffer.LongLength; | 695 | response.ContentLength64 = buffer.LongLength; |
692 | 696 | ||
693 | response.OutputStream.Write(buffer, 0, buffer.Length); | 697 | response.OutputStream.Write(buffer, 0, buffer.Length); |
@@ -1850,8 +1854,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1850 | m_httpListener2.Start(64); | 1854 | m_httpListener2.Start(64); |
1851 | 1855 | ||
1852 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 1856 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1853 | // m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); | ||
1854 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); | 1857 | m_PollServiceManager = new PollServiceRequestManager(this, 4, 25000); |
1858 | m_PollServiceManager.Start(); | ||
1855 | HTTPDRunning = true; | 1859 | HTTPDRunning = true; |
1856 | 1860 | ||
1857 | //HttpListenerContext context; | 1861 | //HttpListenerContext context; |
@@ -1870,6 +1874,21 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1870 | // useful without inbound HTTP. | 1874 | // useful without inbound HTTP. |
1871 | throw e; | 1875 | throw e; |
1872 | } | 1876 | } |
1877 | |||
1878 | m_requestsProcessedStat | ||
1879 | = new Stat( | ||
1880 | "HTTPRequestsServed", | ||
1881 | "Number of inbound HTTP requests processed", | ||
1882 | "", | ||
1883 | "requests", | ||
1884 | "httpserver", | ||
1885 | Port.ToString(), | ||
1886 | StatType.Pull, | ||
1887 | MeasuresOfInterest.AverageChangeOverTime, | ||
1888 | stat => stat.Value = RequestNumber, | ||
1889 | StatVerbosity.Debug); | ||
1890 | |||
1891 | StatsManager.RegisterStat(m_requestsProcessedStat); | ||
1873 | } | 1892 | } |
1874 | 1893 | ||
1875 | public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) | 1894 | public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) |
@@ -1902,9 +1921,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1902 | public void Stop() | 1921 | public void Stop() |
1903 | { | 1922 | { |
1904 | HTTPDRunning = false; | 1923 | HTTPDRunning = false; |
1924 | |||
1925 | StatsManager.DeregisterStat(m_requestsProcessedStat); | ||
1926 | |||
1905 | try | 1927 | try |
1906 | { | 1928 | { |
1907 | // m_PollServiceManager.Stop(); | 1929 | m_PollServiceManager.Stop(); |
1908 | 1930 | ||
1909 | m_httpListener2.ExceptionThrown -= httpServerException; | 1931 | m_httpListener2.ExceptionThrown -= httpServerException; |
1910 | //m_httpListener2.DisconnectHandler = null; | 1932 | //m_httpListener2.DisconnectHandler = null; |