diff options
author | Melanie | 2013-06-23 01:59:57 +0100 |
---|---|---|
committer | Melanie | 2013-06-23 01:59:57 +0100 |
commit | f70357eaa355b8c152f3d793d0fceafa14df5fd4 (patch) | |
tree | ffda32c340bd7f6d69652e9d9a959c7396f42a2f /OpenSim/Framework/Servers | |
parent | Merge branch 'avination-current' into careminster (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.zip opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.gz opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.bz2 opensim-SC_OLD-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Framework/Monitoring/BaseStatsCollector.cs
OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 46 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 30 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs | 20 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/ServerBase.cs | 95 |
4 files changed, 139 insertions, 52 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 6c04c69..bfd67c7 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -86,26 +86,23 @@ namespace OpenSim.Framework.Servers | |||
86 | /// </summary> | 86 | /// </summary> |
87 | protected virtual void StartupSpecific() | 87 | protected virtual void StartupSpecific() |
88 | { | 88 | { |
89 | if (m_console == null) | 89 | StatsManager.SimExtraStats = new SimExtraStatsCollector(); |
90 | return; | ||
91 | |||
92 | RegisterCommonCommands(); | 90 | RegisterCommonCommands(); |
93 | 91 | RegisterCommonComponents(Config); | |
94 | m_console.Commands.AddCommand("General", false, "quit", | 92 | } |
95 | "quit", | 93 | |
96 | "Quit the application", HandleQuit); | 94 | protected override void ShutdownSpecific() |
95 | { | ||
96 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | ||
97 | |||
98 | RemovePIDFile(); | ||
97 | 99 | ||
98 | m_console.Commands.AddCommand("General", false, "shutdown", | 100 | base.ShutdownSpecific(); |
99 | "shutdown", | 101 | |
100 | "Quit the application", HandleQuit); | 102 | Environment.Exit(0); |
101 | } | 103 | } |
102 | 104 | ||
103 | /// <summary> | 105 | /// <summary> |
104 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
105 | /// </summary> | ||
106 | public virtual void ShutdownSpecific() {} | ||
107 | |||
108 | /// <summary> | ||
109 | /// Provides a list of help topics that are available. Overriding classes should append their topics to the | 106 | /// Provides a list of help topics that are available. Overriding classes should append their topics to the |
110 | /// information returned when the base method is called. | 107 | /// information returned when the base method is called. |
111 | /// </summary> | 108 | /// </summary> |
@@ -153,25 +150,8 @@ namespace OpenSim.Framework.Servers | |||
153 | timeTaken.Minutes, timeTaken.Seconds); | 150 | timeTaken.Minutes, timeTaken.Seconds); |
154 | } | 151 | } |
155 | 152 | ||
156 | /// <summary> | 153 | public string osSecret |
157 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
158 | /// </summary> | ||
159 | public virtual void Shutdown() | ||
160 | { | 154 | { |
161 | ShutdownSpecific(); | ||
162 | |||
163 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | ||
164 | RemovePIDFile(); | ||
165 | |||
166 | Environment.Exit(0); | ||
167 | } | ||
168 | |||
169 | private void HandleQuit(string module, string[] args) | ||
170 | { | ||
171 | Shutdown(); | ||
172 | } | ||
173 | |||
174 | public string osSecret { | ||
175 | // Secret uuid for the simulator | 155 | // Secret uuid for the simulator |
176 | get { return m_osSecret; } | 156 | get { return m_osSecret; } |
177 | } | 157 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index d29cc61..80d1080 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 | ||
@@ -437,9 +441,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
437 | } | 441 | } |
438 | } | 442 | } |
439 | 443 | ||
440 | public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) | 444 | private void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) |
441 | { | 445 | { |
442 | |||
443 | OSHttpRequest req = new OSHttpRequest(context, request); | 446 | OSHttpRequest req = new OSHttpRequest(context, request); |
444 | WebSocketRequestDelegate dWebSocketRequestDelegate = null; | 447 | WebSocketRequestDelegate dWebSocketRequestDelegate = null; |
445 | lock (m_WebSocketHandlers) | 448 | lock (m_WebSocketHandlers) |
@@ -455,8 +458,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
455 | 458 | ||
456 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); | 459 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); |
457 | resp.ReuseContext = true; | 460 | resp.ReuseContext = true; |
458 | HandleRequest(req, resp); | 461 | HandleRequest(req, resp); |
459 | |||
460 | 462 | ||
461 | // !!!HACK ALERT!!! | 463 | // !!!HACK ALERT!!! |
462 | // There seems to be a bug in the underlying http code that makes subsequent requests | 464 | // There seems to be a bug in the underlying http code that makes subsequent requests |
@@ -1870,6 +1872,21 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1870 | // useful without inbound HTTP. | 1872 | // useful without inbound HTTP. |
1871 | throw e; | 1873 | throw e; |
1872 | } | 1874 | } |
1875 | |||
1876 | m_requestsProcessedStat | ||
1877 | = new Stat( | ||
1878 | "HTTPRequestsServed", | ||
1879 | "Number of inbound HTTP requests processed", | ||
1880 | "", | ||
1881 | "requests", | ||
1882 | "httpserver", | ||
1883 | Port.ToString(), | ||
1884 | StatType.Pull, | ||
1885 | MeasuresOfInterest.AverageChangeOverTime, | ||
1886 | stat => stat.Value = RequestNumber, | ||
1887 | StatVerbosity.Debug); | ||
1888 | |||
1889 | StatsManager.RegisterStat(m_requestsProcessedStat); | ||
1873 | } | 1890 | } |
1874 | 1891 | ||
1875 | public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) | 1892 | public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) |
@@ -1902,6 +1919,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1902 | public void Stop() | 1919 | public void Stop() |
1903 | { | 1920 | { |
1904 | HTTPDRunning = false; | 1921 | HTTPDRunning = false; |
1922 | |||
1923 | StatsManager.DeregisterStat(m_requestsProcessedStat); | ||
1924 | |||
1905 | try | 1925 | try |
1906 | { | 1926 | { |
1907 | m_PollServiceManager.Stop(); | 1927 | m_PollServiceManager.Stop(); |
diff --git a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs index ee96b47..de89e2e 100644 --- a/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/WebsocketServerHandler.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
75 | /// <summary> | 75 | /// <summary> |
76 | /// This is a regular HTTP Request... This may be removed in the future. | 76 | /// This is a regular HTTP Request... This may be removed in the future. |
77 | /// </summary> | 77 | /// </summary> |
78 | public event RegularHttpRequestDelegate OnRegularHttpRequest; | 78 | // public event RegularHttpRequestDelegate OnRegularHttpRequest; |
79 | 79 | ||
80 | /// <summary> | 80 | /// <summary> |
81 | /// When the upgrade from a HTTP request to a Websocket is completed, this will be fired | 81 | /// When the upgrade from a HTTP request to a Websocket is completed, this will be fired |
@@ -304,15 +304,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
304 | if (d != null) | 304 | if (d != null) |
305 | d(this, new UpgradeCompletedEventArgs()); | 305 | d(this, new UpgradeCompletedEventArgs()); |
306 | } | 306 | } |
307 | catch (IOException fail) | 307 | catch (IOException) |
308 | { | 308 | { |
309 | Close(string.Empty); | 309 | Close(string.Empty); |
310 | } | 310 | } |
311 | catch (ObjectDisposedException fail) | 311 | catch (ObjectDisposedException) |
312 | { | 312 | { |
313 | Close(string.Empty); | 313 | Close(string.Empty); |
314 | } | 314 | } |
315 | |||
316 | } | 315 | } |
317 | 316 | ||
318 | /// <summary> | 317 | /// <summary> |
@@ -414,8 +413,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
414 | _socketState.Header = pheader; | 413 | _socketState.Header = pheader; |
415 | } | 414 | } |
416 | 415 | ||
417 | |||
418 | |||
419 | if (_socketState.FrameComplete) | 416 | if (_socketState.FrameComplete) |
420 | { | 417 | { |
421 | ProcessFrame(_socketState); | 418 | ProcessFrame(_socketState); |
@@ -424,7 +421,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
424 | _socketState.ExpectedBytes = 0; | 421 | _socketState.ExpectedBytes = 0; |
425 | 422 | ||
426 | } | 423 | } |
427 | |||
428 | } | 424 | } |
429 | } | 425 | } |
430 | else | 426 | else |
@@ -457,8 +453,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
457 | _socketState.ReceivedBytes.Clear(); | 453 | _socketState.ReceivedBytes.Clear(); |
458 | _socketState.ExpectedBytes = 0; | 454 | _socketState.ExpectedBytes = 0; |
459 | // do some processing | 455 | // do some processing |
460 | } | 456 | } |
461 | |||
462 | } | 457 | } |
463 | } | 458 | } |
464 | if (offset > 0) | 459 | if (offset > 0) |
@@ -477,13 +472,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
477 | { | 472 | { |
478 | // We can't read the stream anymore... | 473 | // We can't read the stream anymore... |
479 | } | 474 | } |
480 | |||
481 | } | 475 | } |
482 | catch (IOException fail) | 476 | catch (IOException) |
483 | { | 477 | { |
484 | Close(string.Empty); | 478 | Close(string.Empty); |
485 | } | 479 | } |
486 | catch (ObjectDisposedException fail) | 480 | catch (ObjectDisposedException) |
487 | { | 481 | { |
488 | Close(string.Empty); | 482 | Close(string.Empty); |
489 | } | 483 | } |
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index b9e3c18..eb8c9f8 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -62,6 +62,8 @@ namespace OpenSim.Framework.Servers | |||
62 | 62 | ||
63 | protected string m_pidFile = String.Empty; | 63 | protected string m_pidFile = String.Empty; |
64 | 64 | ||
65 | protected ServerStatsCollector m_serverStatsCollector; | ||
66 | |||
65 | /// <summary> | 67 | /// <summary> |
66 | /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. | 68 | /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. |
67 | /// </summary> | 69 | /// </summary> |
@@ -259,6 +261,25 @@ namespace OpenSim.Framework.Servers | |||
259 | "force gc", | 261 | "force gc", |
260 | "Manually invoke runtime garbage collection. For debugging purposes", | 262 | "Manually invoke runtime garbage collection. For debugging purposes", |
261 | HandleForceGc); | 263 | HandleForceGc); |
264 | |||
265 | m_console.Commands.AddCommand( | ||
266 | "General", false, "quit", | ||
267 | "quit", | ||
268 | "Quit the application", (mod, args) => Shutdown()); | ||
269 | |||
270 | m_console.Commands.AddCommand( | ||
271 | "General", false, "shutdown", | ||
272 | "shutdown", | ||
273 | "Quit the application", (mod, args) => Shutdown()); | ||
274 | |||
275 | StatsManager.RegisterConsoleCommands(m_console); | ||
276 | } | ||
277 | |||
278 | public void RegisterCommonComponents(IConfigSource configSource) | ||
279 | { | ||
280 | m_serverStatsCollector = new ServerStatsCollector(); | ||
281 | m_serverStatsCollector.Initialise(configSource); | ||
282 | m_serverStatsCollector.Start(); | ||
262 | } | 283 | } |
263 | 284 | ||
264 | private void HandleForceGc(string module, string[] args) | 285 | private void HandleForceGc(string module, string[] args) |
@@ -646,7 +667,68 @@ namespace OpenSim.Framework.Servers | |||
646 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); | 667 | sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); |
647 | 668 | ||
648 | sb.Append("Main threadpool (excluding script engine pools)\n"); | 669 | sb.Append("Main threadpool (excluding script engine pools)\n"); |
649 | sb.Append(Util.GetThreadPoolReport()); | 670 | sb.Append(GetThreadPoolReport()); |
671 | |||
672 | return sb.ToString(); | ||
673 | } | ||
674 | |||
675 | /// <summary> | ||
676 | /// Get a thread pool report. | ||
677 | /// </summary> | ||
678 | /// <returns></returns> | ||
679 | public static string GetThreadPoolReport() | ||
680 | { | ||
681 | string threadPoolUsed = null; | ||
682 | int maxThreads = 0; | ||
683 | int minThreads = 0; | ||
684 | int allocatedThreads = 0; | ||
685 | int inUseThreads = 0; | ||
686 | int waitingCallbacks = 0; | ||
687 | int completionPortThreads = 0; | ||
688 | |||
689 | StringBuilder sb = new StringBuilder(); | ||
690 | if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) | ||
691 | { | ||
692 | STPInfo stpi = Util.GetSmartThreadPoolInfo(); | ||
693 | |||
694 | // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool. | ||
695 | if (stpi != null) | ||
696 | { | ||
697 | threadPoolUsed = "SmartThreadPool"; | ||
698 | maxThreads = stpi.MaxThreads; | ||
699 | minThreads = stpi.MinThreads; | ||
700 | inUseThreads = stpi.InUseThreads; | ||
701 | allocatedThreads = stpi.ActiveThreads; | ||
702 | waitingCallbacks = stpi.WaitingCallbacks; | ||
703 | } | ||
704 | } | ||
705 | else if ( | ||
706 | Util.FireAndForgetMethod == FireAndForgetMethod.QueueUserWorkItem | ||
707 | || Util.FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem) | ||
708 | { | ||
709 | threadPoolUsed = "BuiltInThreadPool"; | ||
710 | ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads); | ||
711 | ThreadPool.GetMinThreads(out minThreads, out completionPortThreads); | ||
712 | int availableThreads; | ||
713 | ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads); | ||
714 | inUseThreads = maxThreads - availableThreads; | ||
715 | allocatedThreads = -1; | ||
716 | waitingCallbacks = -1; | ||
717 | } | ||
718 | |||
719 | if (threadPoolUsed != null) | ||
720 | { | ||
721 | sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); | ||
722 | sb.AppendFormat("Max threads : {0}\n", maxThreads); | ||
723 | sb.AppendFormat("Min threads : {0}\n", minThreads); | ||
724 | sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString()); | ||
725 | sb.AppendFormat("In use threads : {0}\n", inUseThreads); | ||
726 | sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString()); | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | sb.AppendFormat("Thread pool not used\n"); | ||
731 | } | ||
650 | 732 | ||
651 | return sb.ToString(); | 733 | return sb.ToString(); |
652 | } | 734 | } |
@@ -698,5 +780,16 @@ namespace OpenSim.Framework.Servers | |||
698 | if (m_console != null) | 780 | if (m_console != null) |
699 | m_console.OutputFormat(format, components); | 781 | m_console.OutputFormat(format, components); |
700 | } | 782 | } |
783 | |||
784 | public virtual void Shutdown() | ||
785 | { | ||
786 | m_serverStatsCollector.Close(); | ||
787 | ShutdownSpecific(); | ||
788 | } | ||
789 | |||
790 | /// <summary> | ||
791 | /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing | ||
792 | /// </summary> | ||
793 | protected virtual void ShutdownSpecific() {} | ||
701 | } | 794 | } |
702 | } | 795 | } |