diff options
author | Melanie | 2011-10-26 01:27:24 +0100 |
---|---|---|
committer | Melanie | 2011-10-26 01:27:24 +0100 |
commit | fd22159d0c7d7b149d35747cbaa436f3b1e6f579 (patch) | |
tree | bbe8cdc63dd1f98346a6afb844f4b4d3caf336a8 /OpenSim/Framework | |
parent | Merge commit 'e14cb45b9bc4c78300cb804833cb66c1c2e62187' into bigmerge (diff) | |
parent | Restart the event queue worker threads that I accidentally disabled earlier t... (diff) | |
download | opensim-SC-fd22159d0c7d7b149d35747cbaa436f3b1e6f579.zip opensim-SC-fd22159d0c7d7b149d35747cbaa436f3b1e6f579.tar.gz opensim-SC-fd22159d0c7d7b149d35747cbaa436f3b1e6f579.tar.bz2 opensim-SC-fd22159d0c7d7b149d35747cbaa436f3b1e6f579.tar.xz |
Merge branch 'master' into bigmerge
Conflicts:
OpenSim/Framework/Watchdog.cs
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/ConfigurationMember.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Console/CommandConsole.cs | 11 | ||||
-rwxr-xr-x | OpenSim/Framework/Console/ConsoleBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/ICommandConsole.cs | 90 | ||||
-rw-r--r-- | OpenSim/Framework/IConsole.cs | 53 | ||||
-rw-r--r-- | OpenSim/Framework/IScene.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/MainConsole.cs (renamed from OpenSim/Framework/Console/MainConsole.cs) | 6 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 30 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 40 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/MainServer.cs (renamed from OpenSim/Framework/MainServer.cs) | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Watchdog.cs | 102 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 60 |
15 files changed, 330 insertions, 80 deletions
diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs index b4ce877..7afa68a 100644 --- a/OpenSim/Framework/ConfigurationMember.cs +++ b/OpenSim/Framework/ConfigurationMember.cs | |||
@@ -33,7 +33,7 @@ using System.Reflection; | |||
33 | using System.Xml; | 33 | using System.Xml; |
34 | using log4net; | 34 | using log4net; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework.Console; | 36 | //using OpenSim.Framework.Console; |
37 | 37 | ||
38 | namespace OpenSim.Framework | 38 | namespace OpenSim.Framework |
39 | { | 39 | { |
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index be36cf2..f10b857 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -33,12 +33,11 @@ using System.Reflection; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | ||
36 | 37 | ||
37 | namespace OpenSim.Framework.Console | 38 | namespace OpenSim.Framework.Console |
38 | { | 39 | { |
39 | public delegate void CommandDelegate(string module, string[] cmd); | 40 | public class Commands : ICommands |
40 | |||
41 | public class Commands | ||
42 | { | 41 | { |
43 | /// <summary> | 42 | /// <summary> |
44 | /// Encapsulates a command that can be invoked from the console | 43 | /// Encapsulates a command that can be invoked from the console |
@@ -564,14 +563,16 @@ namespace OpenSim.Framework.Console | |||
564 | /// <summary> | 563 | /// <summary> |
565 | /// A console that processes commands internally | 564 | /// A console that processes commands internally |
566 | /// </summary> | 565 | /// </summary> |
567 | public class CommandConsole : ConsoleBase | 566 | public class CommandConsole : ConsoleBase, ICommandConsole |
568 | { | 567 | { |
569 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 568 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
570 | 569 | ||
571 | public Commands Commands = new Commands(); | 570 | public ICommands Commands { get; private set; } |
572 | 571 | ||
573 | public CommandConsole(string defaultPrompt) : base(defaultPrompt) | 572 | public CommandConsole(string defaultPrompt) : base(defaultPrompt) |
574 | { | 573 | { |
574 | Commands = new Commands(); | ||
575 | |||
575 | Commands.AddCommand("console", false, "help", "help [<command>]", | 576 | Commands.AddCommand("console", false, "help", "help [<command>]", |
576 | "Get general command list or more detailed help on a specific command", Help); | 577 | "Get general command list or more detailed help on a specific command", Help); |
577 | } | 578 | } |
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index c59fbca..4b375d9 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Framework.Console | |||
41 | 41 | ||
42 | protected string prompt = "# "; | 42 | protected string prompt = "# "; |
43 | 43 | ||
44 | public object ConsoleScene = null; | 44 | public object ConsoleScene { get; set; } |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// The default prompt text. | 47 | /// The default prompt text. |
diff --git a/OpenSim/Framework/ICommandConsole.cs b/OpenSim/Framework/ICommandConsole.cs new file mode 100644 index 0000000..d33b9b5 --- /dev/null +++ b/OpenSim/Framework/ICommandConsole.cs | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Xml; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | public delegate void CommandDelegate(string module, string[] cmd); | ||
35 | |||
36 | public interface ICommands | ||
37 | { | ||
38 | void FromXml(XmlElement root, CommandDelegate fn); | ||
39 | |||
40 | /// <summary> | ||
41 | /// Get help for the given help string | ||
42 | /// </summary> | ||
43 | /// <param name="helpParts">Parsed parts of the help string. If empty then general help is returned.</param> | ||
44 | /// <returns></returns> | ||
45 | List<string> GetHelp(string[] cmd); | ||
46 | |||
47 | /// <summary> | ||
48 | /// Add a command to those which can be invoked from the console. | ||
49 | /// </summary> | ||
50 | /// <param name="module"></param> | ||
51 | /// <param name="command"></param> | ||
52 | /// <param name="help"></param> | ||
53 | /// <param name="longhelp"></param> | ||
54 | /// <param name="fn"></param> | ||
55 | void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn); | ||
56 | |||
57 | /// <summary> | ||
58 | /// Add a command to those which can be invoked from the console. | ||
59 | /// </summary> | ||
60 | /// <param name="module"></param> | ||
61 | /// <param name="command"></param> | ||
62 | /// <param name="help"></param> | ||
63 | /// <param name="longhelp"></param> | ||
64 | /// <param name="descriptivehelp"></param> | ||
65 | /// <param name="fn"></param> | ||
66 | void AddCommand(string module, bool shared, string command, | ||
67 | string help, string longhelp, string descriptivehelp, | ||
68 | CommandDelegate fn); | ||
69 | |||
70 | string[] FindNextOption(string[] cmd, bool term); | ||
71 | |||
72 | string[] Resolve(string[] cmd); | ||
73 | |||
74 | XmlElement GetXml(XmlDocument doc); | ||
75 | } | ||
76 | |||
77 | public interface ICommandConsole : IConsole | ||
78 | { | ||
79 | ICommands Commands { get; } | ||
80 | |||
81 | /// <summary> | ||
82 | /// Display a command prompt on the console and wait for user input | ||
83 | /// </summary> | ||
84 | void Prompt(); | ||
85 | |||
86 | void RunCommand(string cmd); | ||
87 | |||
88 | string ReadLine(string p, bool isCommand, bool e); | ||
89 | } | ||
90 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/IConsole.cs b/OpenSim/Framework/IConsole.cs new file mode 100644 index 0000000..33024b2 --- /dev/null +++ b/OpenSim/Framework/IConsole.cs | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace OpenSim.Framework | ||
32 | { | ||
33 | public interface IConsole | ||
34 | { | ||
35 | object ConsoleScene { get; } | ||
36 | |||
37 | void Output(string text, string level); | ||
38 | void Output(string text); | ||
39 | void OutputFormat(string format, params object[] components); | ||
40 | |||
41 | string CmdPrompt(string p); | ||
42 | string CmdPrompt(string p, string def); | ||
43 | string CmdPrompt(string p, List<char> excludedCharacters); | ||
44 | string CmdPrompt(string p, string def, List<char> excludedCharacters); | ||
45 | |||
46 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | ||
47 | string CmdPrompt(string prompt, string defaultresponse, List<string> options); | ||
48 | |||
49 | // Displays a prompt and waits for the user to enter a string, then returns that string | ||
50 | // (Done with no echo and suitable for passwords) | ||
51 | string PasswdPrompt(string p); | ||
52 | } | ||
53 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index e0cb897..f1b4732 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -26,7 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Framework.Console; | 29 | //using OpenSim.Framework.Console; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | 31 | ||
32 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
@@ -108,7 +108,7 @@ namespace OpenSim.Framework | |||
108 | void RegisterModuleInterface<M>(M mod); | 108 | void RegisterModuleInterface<M>(M mod); |
109 | void StackModuleInterface<M>(M mod); | 109 | void StackModuleInterface<M>(M mod); |
110 | 110 | ||
111 | void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); | 111 | // void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); |
112 | 112 | ||
113 | ISceneObject DeserializeObject(string representation); | 113 | ISceneObject DeserializeObject(string representation); |
114 | 114 | ||
diff --git a/OpenSim/Framework/Console/MainConsole.cs b/OpenSim/Framework/MainConsole.cs index 24be617..4527b68 100644 --- a/OpenSim/Framework/Console/MainConsole.cs +++ b/OpenSim/Framework/MainConsole.cs | |||
@@ -25,13 +25,13 @@ | |||
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 | namespace OpenSim.Framework.Console | 28 | namespace OpenSim.Framework |
29 | { | 29 | { |
30 | public class MainConsole | 30 | public class MainConsole |
31 | { | 31 | { |
32 | private static CommandConsole instance; | 32 | private static ICommandConsole instance; |
33 | 33 | ||
34 | public static CommandConsole Instance | 34 | public static ICommandConsole Instance |
35 | { | 35 | { |
36 | get { return instance; } | 36 | get { return instance; } |
37 | set { instance = value; } | 37 | set { instance = value; } |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index b0202fb..db6c26f 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -36,7 +36,7 @@ using log4net; | |||
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenMetaverse.StructuredData; | 38 | using OpenMetaverse.StructuredData; |
39 | using OpenSim.Framework.Console; | 39 | //using OpenSim.Framework.Console; |
40 | 40 | ||
41 | namespace OpenSim.Framework | 41 | namespace OpenSim.Framework |
42 | { | 42 | { |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 64b9c3e..66d0813 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -192,6 +192,15 @@ namespace OpenSim.Framework.Servers | |||
192 | m_console.Commands.AddCommand("base", false, "show version", | 192 | m_console.Commands.AddCommand("base", false, "show version", |
193 | "show version", | 193 | "show version", |
194 | "Show server version", HandleShow); | 194 | "Show server version", HandleShow); |
195 | |||
196 | m_console.Commands.AddCommand("base", false, "threads abort", | ||
197 | "threads abort <thread-id>", | ||
198 | "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); | ||
199 | |||
200 | m_console.Commands.AddCommand("base", false, "threads show", | ||
201 | "threads show", | ||
202 | "Show thread status. Synonym for \"show threads\"", | ||
203 | (string module, string[] args) => Notice(GetThreadsReport())); | ||
195 | } | 204 | } |
196 | } | 205 | } |
197 | 206 | ||
@@ -395,6 +404,27 @@ namespace OpenSim.Framework.Servers | |||
395 | break; | 404 | break; |
396 | } | 405 | } |
397 | } | 406 | } |
407 | |||
408 | public virtual void HandleThreadsAbort(string module, string[] cmd) | ||
409 | { | ||
410 | if (cmd.Length != 3) | ||
411 | { | ||
412 | MainConsole.Instance.Output("Usage: threads abort <thread-id>"); | ||
413 | return; | ||
414 | } | ||
415 | |||
416 | int threadId; | ||
417 | if (!int.TryParse(cmd[2], out threadId)) | ||
418 | { | ||
419 | MainConsole.Instance.Output("ERROR: Thread id must be an integer"); | ||
420 | return; | ||
421 | } | ||
422 | |||
423 | if (Watchdog.AbortThread(threadId)) | ||
424 | MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); | ||
425 | else | ||
426 | MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); | ||
427 | } | ||
398 | 428 | ||
399 | protected void ShowInfo() | 429 | protected void ShowInfo() |
400 | { | 430 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 65b1eb5..fd77984 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | |||
@@ -49,7 +49,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Add a handler for an HTTP request. | 50 | /// Add a handler for an HTTP request. |
51 | /// </summary> | 51 | /// </summary> |
52 | /// | 52 | /// <remarks> |
53 | /// This handler can actually be invoked either as | 53 | /// This handler can actually be invoked either as |
54 | /// | 54 | /// |
55 | /// http://<hostname>:<port>/?method=<methodName> | 55 | /// http://<hostname>:<port>/?method=<methodName> |
@@ -70,7 +70,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
70 | /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request | 70 | /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request |
71 | /// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then | 71 | /// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then |
72 | /// the "/myapp/" handler is invoked if no "/myapp/page" handler exists. | 72 | /// the "/myapp/" handler is invoked if no "/myapp/page" handler exists. |
73 | /// | 73 | /// </remarks> |
74 | /// <param name="methodName"></param> | 74 | /// <param name="methodName"></param> |
75 | /// <param name="handler"></param> | 75 | /// <param name="handler"></param> |
76 | /// <returns> | 76 | /// <returns> |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 0840a9d..d9965b6 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -31,6 +31,7 @@ using System.Threading; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using HttpServer; | 33 | using HttpServer; |
34 | using OpenSim.Framework; | ||
34 | 35 | ||
35 | namespace OpenSim.Framework.Servers.HttpServer | 36 | namespace OpenSim.Framework.Servers.HttpServer |
36 | { | 37 | { |
@@ -54,21 +55,27 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; | 55 | m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; |
55 | 56 | ||
56 | //startup worker threads | 57 | //startup worker threads |
57 | for (uint i=0;i<m_WorkerThreadCount;i++) | 58 | for (uint i = 0; i < m_WorkerThreadCount; i++) |
58 | { | 59 | { |
59 | m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout); | 60 | m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout); |
60 | m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent; | 61 | m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent; |
61 | 62 | ||
62 | m_workerThreads[i] = new Thread(m_PollServiceWorkerThreads[i].ThreadStart); | 63 | m_workerThreads[i] |
63 | m_workerThreads[i].Name = String.Format("PollServiceWorkerThread{0}",i); | 64 | = Watchdog.StartThread( |
64 | //Can't add to thread Tracker here Referencing OpenSim.Framework creates circular reference | 65 | m_PollServiceWorkerThreads[i].ThreadStart, |
65 | m_workerThreads[i].Start(); | 66 | String.Format("PollServiceWorkerThread{0}", i), |
67 | ThreadPriority.Normal, | ||
68 | false, | ||
69 | int.MaxValue); | ||
66 | } | 70 | } |
67 | 71 | ||
68 | //start watcher threads | 72 | m_watcherThread |
69 | m_watcherThread = new Thread(ThreadStart); | 73 | = Watchdog.StartThread( |
70 | m_watcherThread.Name = "PollServiceWatcherThread"; | 74 | this.ThreadStart, |
71 | m_watcherThread.Start(); | 75 | "PollServiceWatcherThread", |
76 | ThreadPriority.Normal, | ||
77 | false, | ||
78 | 1000 * 60 * 10); | ||
72 | } | 79 | } |
73 | 80 | ||
74 | internal void ReQueueEvent(PollServiceHttpRequest req) | 81 | internal void ReQueueEvent(PollServiceHttpRequest req) |
@@ -83,10 +90,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
83 | m_requests.Enqueue(req); | 90 | m_requests.Enqueue(req); |
84 | } | 91 | } |
85 | 92 | ||
86 | public void ThreadStart(object o) | 93 | public void ThreadStart() |
87 | { | 94 | { |
88 | while (m_running) | 95 | while (m_running) |
89 | { | 96 | { |
97 | Watchdog.UpdateThread(); | ||
90 | ProcessQueuedRequests(); | 98 | ProcessQueuedRequests(); |
91 | Thread.Sleep(1000); | 99 | Thread.Sleep(1000); |
92 | } | 100 | } |
@@ -107,7 +115,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
107 | for (int tc = 0; tc < m_WorkerThreadCount && m_requests.Count > 0; tc++) | 115 | for (int tc = 0; tc < m_WorkerThreadCount && m_requests.Count > 0; tc++) |
108 | { | 116 | { |
109 | //Loop over number of requests each thread handles. | 117 | //Loop over number of requests each thread handles. |
110 | for (int i=0;i<reqperthread && m_requests.Count > 0;i++) | 118 | for (int i = 0; i < reqperthread && m_requests.Count > 0; i++) |
111 | { | 119 | { |
112 | try | 120 | try |
113 | { | 121 | { |
@@ -125,14 +133,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
125 | 133 | ||
126 | } | 134 | } |
127 | 135 | ||
128 | |||
129 | |||
130 | ~PollServiceRequestManager() | 136 | ~PollServiceRequestManager() |
131 | { | 137 | { |
132 | foreach (object o in m_requests) | 138 | foreach (object o in m_requests) |
133 | { | 139 | { |
134 | PollServiceHttpRequest req = (PollServiceHttpRequest) o; | 140 | PollServiceHttpRequest req = (PollServiceHttpRequest) o; |
135 | m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); | 141 | m_server.DoHTTPGruntWork( |
142 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), | ||
143 | new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); | ||
136 | } | 144 | } |
137 | 145 | ||
138 | m_requests.Clear(); | 146 | m_requests.Clear(); |
@@ -144,4 +152,4 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
144 | m_running = false; | 152 | m_running = false; |
145 | } | 153 | } |
146 | } | 154 | } |
147 | } | 155 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index b91496b..16e56d2 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
59 | m_timeout = pTimeout; | 59 | m_timeout = pTimeout; |
60 | } | 60 | } |
61 | 61 | ||
62 | public void ThreadStart(object o) | 62 | public void ThreadStart() |
63 | { | 63 | { |
64 | Run(); | 64 | Run(); |
65 | } | 65 | } |
diff --git a/OpenSim/Framework/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index a3e0a26..b8ab8d9 100644 --- a/OpenSim/Framework/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -31,7 +31,7 @@ using System.Net; | |||
31 | using log4net; | 31 | using log4net; |
32 | using OpenSim.Framework.Servers.HttpServer; | 32 | using OpenSim.Framework.Servers.HttpServer; |
33 | 33 | ||
34 | namespace OpenSim.Framework | 34 | namespace OpenSim.Framework.Servers |
35 | { | 35 | { |
36 | public class MainServer | 36 | public class MainServer |
37 | { | 37 | { |
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index 3389ecb..952f039 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs | |||
@@ -40,19 +40,31 @@ namespace OpenSim.Framework | |||
40 | { | 40 | { |
41 | /// <summary>Timer interval in milliseconds for the watchdog timer</summary> | 41 | /// <summary>Timer interval in milliseconds for the watchdog timer</summary> |
42 | const double WATCHDOG_INTERVAL_MS = 2500.0d; | 42 | const double WATCHDOG_INTERVAL_MS = 2500.0d; |
43 | |||
43 | /// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary> | 44 | /// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary> |
44 | const int WATCHDOG_TIMEOUT_MS = 5000; | 45 | const int WATCHDOG_TIMEOUT_MS = 5000; |
45 | 46 | ||
46 | [System.Diagnostics.DebuggerDisplay("{Thread.Name}")] | 47 | [System.Diagnostics.DebuggerDisplay("{Thread.Name}")] |
47 | public class ThreadWatchdogInfo | 48 | public class ThreadWatchdogInfo |
48 | { | 49 | { |
49 | public Thread Thread; | 50 | public Thread Thread { get; private set; } |
50 | public int LastTick; | 51 | public int LastTick { get; set; } |
52 | |||
53 | /// <summary> | ||
54 | /// Number of milliseconds before we notify that the thread is having a problem. | ||
55 | /// </summary> | ||
56 | public int Timeout { get; set; } | ||
57 | |||
58 | /// <summary> | ||
59 | /// Is this thread considered timed out? | ||
60 | /// </summary> | ||
61 | public bool IsTimedOut { get; set; } | ||
51 | 62 | ||
52 | public ThreadWatchdogInfo(Thread thread) | 63 | public ThreadWatchdogInfo(Thread thread, int timeout) |
53 | { | 64 | { |
54 | Thread = thread; | 65 | Thread = thread; |
55 | LastTick = Environment.TickCount; | 66 | Timeout = timeout; |
67 | LastTick = Environment.TickCount & Int32.MaxValue; | ||
56 | } | 68 | } |
57 | } | 69 | } |
58 | 70 | ||
@@ -82,7 +94,7 @@ namespace OpenSim.Framework | |||
82 | } | 94 | } |
83 | 95 | ||
84 | /// <summary> | 96 | /// <summary> |
85 | /// Start a new thread that is tracked by the watchdog timer | 97 | /// Start a new thread that is tracked by the watchdog timer. |
86 | /// </summary> | 98 | /// </summary> |
87 | /// <param name="start">The method that will be executed in a new thread</param> | 99 | /// <param name="start">The method that will be executed in a new thread</param> |
88 | /// <param name="name">A name to give to the new thread</param> | 100 | /// <param name="name">A name to give to the new thread</param> |
@@ -92,12 +104,37 @@ namespace OpenSim.Framework | |||
92 | /// <returns>The newly created Thread object</returns> | 104 | /// <returns>The newly created Thread object</returns> |
93 | public static Thread StartThread(ThreadStart start, string name, ThreadPriority priority, bool isBackground) | 105 | public static Thread StartThread(ThreadStart start, string name, ThreadPriority priority, bool isBackground) |
94 | { | 106 | { |
107 | return StartThread(start, name, priority, isBackground, WATCHDOG_TIMEOUT_MS); | ||
108 | } | ||
109 | |||
110 | /// <summary> | ||
111 | /// Start a new thread that is tracked by the watchdog timer | ||
112 | /// </summary> | ||
113 | /// <param name="start">The method that will be executed in a new thread</param> | ||
114 | /// <param name="name">A name to give to the new thread</param> | ||
115 | /// <param name="priority">Priority to run the thread at</param> | ||
116 | /// <param name="isBackground">True to run this thread as a background | ||
117 | /// thread, otherwise false</param> | ||
118 | /// <param name="timeout"> | ||
119 | /// Number of milliseconds to wait until we issue a warning about timeout. | ||
120 | /// </para> | ||
121 | /// <returns>The newly created Thread object</returns> | ||
122 | public static Thread StartThread( | ||
123 | ThreadStart start, string name, ThreadPriority priority, bool isBackground, int timeout) | ||
124 | { | ||
95 | Thread thread = new Thread(start); | 125 | Thread thread = new Thread(start); |
96 | thread.Name = name; | 126 | thread.Name = name; |
97 | thread.Priority = priority; | 127 | thread.Priority = priority; |
98 | thread.IsBackground = isBackground; | 128 | thread.IsBackground = isBackground; |
99 | thread.Start(); | 129 | thread.Start(); |
100 | 130 | ||
131 | ThreadWatchdogInfo twi = new ThreadWatchdogInfo(thread, timeout); | ||
132 | |||
133 | m_log.Debug("[WATCHDOG]: Started tracking thread \"" + twi.Thread.Name + "\" (ID " + twi.Thread.ManagedThreadId + ")"); | ||
134 | |||
135 | lock (m_threads) | ||
136 | m_threads.Add(twi.Thread.ManagedThreadId, twi); | ||
137 | |||
101 | return thread; | 138 | return thread; |
102 | } | 139 | } |
103 | 140 | ||
@@ -112,25 +149,42 @@ namespace OpenSim.Framework | |||
112 | /// <summary> | 149 | /// <summary> |
113 | /// Stops watchdog tracking on the current thread | 150 | /// Stops watchdog tracking on the current thread |
114 | /// </summary> | 151 | /// </summary> |
115 | /// <returns>True if the thread was removed from the list of tracked | 152 | /// <returns> |
116 | /// threads, otherwise false</returns> | 153 | /// True if the thread was removed from the list of tracked |
154 | /// threads, otherwise false | ||
155 | /// </returns> | ||
117 | public static bool RemoveThread() | 156 | public static bool RemoveThread() |
118 | { | 157 | { |
119 | return RemoveThread(Thread.CurrentThread.ManagedThreadId); | 158 | return RemoveThread(Thread.CurrentThread.ManagedThreadId); |
120 | } | 159 | } |
121 | 160 | ||
122 | private static void AddThread(ThreadWatchdogInfo threadInfo) | 161 | private static bool RemoveThread(int threadID) |
123 | { | 162 | { |
124 | m_log.Debug("[WATCHDOG]: Started tracking thread \"" + threadInfo.Thread.Name + "\" (ID " + threadInfo.Thread.ManagedThreadId + ")"); | ||
125 | |||
126 | lock (m_threads) | 163 | lock (m_threads) |
127 | m_threads.Add(threadInfo.Thread.ManagedThreadId, threadInfo); | 164 | return m_threads.Remove(threadID); |
128 | } | 165 | } |
129 | 166 | ||
167 | <<<<<<< HEAD:OpenSim/Framework/Watchdog.cs | ||
130 | public static bool RemoveThread(int threadID) | 168 | public static bool RemoveThread(int threadID) |
169 | ======= | ||
170 | public static bool AbortThread(int threadID) | ||
171 | >>>>>>> master:OpenSim/Framework/Watchdog.cs | ||
131 | { | 172 | { |
132 | lock (m_threads) | 173 | lock (m_threads) |
133 | return m_threads.Remove(threadID); | 174 | { |
175 | if (m_threads.ContainsKey(threadID)) | ||
176 | { | ||
177 | ThreadWatchdogInfo twi = m_threads[threadID]; | ||
178 | twi.Thread.Abort(); | ||
179 | RemoveThread(threadID); | ||
180 | |||
181 | return true; | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | return false; | ||
186 | } | ||
187 | } | ||
134 | } | 188 | } |
135 | 189 | ||
136 | private static void UpdateThread(int threadID) | 190 | private static void UpdateThread(int threadID) |
@@ -144,9 +198,18 @@ namespace OpenSim.Framework | |||
144 | try | 198 | try |
145 | { | 199 | { |
146 | if (m_threads.TryGetValue(threadID, out threadInfo)) | 200 | if (m_threads.TryGetValue(threadID, out threadInfo)) |
201 | <<<<<<< HEAD:OpenSim/Framework/Watchdog.cs | ||
147 | threadInfo.LastTick = Environment.TickCount; | 202 | threadInfo.LastTick = Environment.TickCount; |
203 | ======= | ||
204 | { | ||
205 | threadInfo.LastTick = Environment.TickCount & Int32.MaxValue; | ||
206 | threadInfo.IsTimedOut = false; | ||
207 | } | ||
208 | >>>>>>> master:OpenSim/Framework/Watchdog.cs | ||
148 | else | 209 | else |
149 | AddThread(new ThreadWatchdogInfo(Thread.CurrentThread)); | 210 | { |
211 | m_log.WarnFormat("[WATCHDOG]: Asked to update thread {0} which is not being monitored", threadID); | ||
212 | } | ||
150 | } | 213 | } |
151 | catch { } | 214 | catch { } |
152 | } | 215 | } |
@@ -157,7 +220,8 @@ namespace OpenSim.Framework | |||
157 | /// <returns></returns> | 220 | /// <returns></returns> |
158 | public static ThreadWatchdogInfo[] GetThreads() | 221 | public static ThreadWatchdogInfo[] GetThreads() |
159 | { | 222 | { |
160 | return m_threads.Values.ToArray(); | 223 | lock (m_threads) |
224 | return m_threads.Values.ToArray(); | ||
161 | } | 225 | } |
162 | 226 | ||
163 | private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) | 227 | private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) |
@@ -174,10 +238,16 @@ namespace OpenSim.Framework | |||
174 | 238 | ||
175 | foreach (ThreadWatchdogInfo threadInfo in m_threads.Values) | 239 | foreach (ThreadWatchdogInfo threadInfo in m_threads.Values) |
176 | { | 240 | { |
177 | if (threadInfo.Thread.ThreadState == ThreadState.Stopped || now - threadInfo.LastTick >= WATCHDOG_TIMEOUT_MS) | 241 | if (threadInfo.Thread.ThreadState == ThreadState.Stopped) |
242 | { | ||
243 | timedOut = threadInfo; | ||
244 | RemoveThread(threadInfo.Thread.ManagedThreadId); | ||
245 | break; | ||
246 | } | ||
247 | else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) | ||
178 | { | 248 | { |
249 | threadInfo.IsTimedOut = true; | ||
179 | timedOut = threadInfo; | 250 | timedOut = threadInfo; |
180 | m_threads.Remove(threadInfo.Thread.ManagedThreadId); | ||
181 | break; | 251 | break; |
182 | } | 252 | } |
183 | } | 253 | } |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 971c0b7..60c1e15 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -39,9 +39,7 @@ using System.Text; | |||
39 | using System.Web; | 39 | using System.Web; |
40 | using System.Xml; | 40 | using System.Xml; |
41 | using System.Xml.Serialization; | 41 | using System.Xml.Serialization; |
42 | |||
43 | using log4net; | 42 | using log4net; |
44 | using OpenSim.Framework.Servers.HttpServer; | ||
45 | using OpenMetaverse.StructuredData; | 43 | using OpenMetaverse.StructuredData; |
46 | 44 | ||
47 | namespace OpenSim.Framework | 45 | namespace OpenSim.Framework |
@@ -65,35 +63,35 @@ namespace OpenSim.Framework | |||
65 | // a "long" call for warning & debugging purposes | 63 | // a "long" call for warning & debugging purposes |
66 | public const int LongCallTime = 500; | 64 | public const int LongCallTime = 500; |
67 | 65 | ||
68 | /// <summary> | 66 | // /// <summary> |
69 | /// Send LLSD to an HTTP client in application/llsd+json form | 67 | // /// Send LLSD to an HTTP client in application/llsd+json form |
70 | /// </summary> | 68 | // /// </summary> |
71 | /// <param name="response">HTTP response to send the data in</param> | 69 | // /// <param name="response">HTTP response to send the data in</param> |
72 | /// <param name="body">LLSD to send to the client</param> | 70 | // /// <param name="body">LLSD to send to the client</param> |
73 | public static void SendJSONResponse(OSHttpResponse response, OSDMap body) | 71 | // public static void SendJSONResponse(OSHttpResponse response, OSDMap body) |
74 | { | 72 | // { |
75 | byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); | 73 | // byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); |
76 | 74 | // | |
77 | response.ContentEncoding = Encoding.UTF8; | 75 | // response.ContentEncoding = Encoding.UTF8; |
78 | response.ContentLength = responseData.Length; | 76 | // response.ContentLength = responseData.Length; |
79 | response.ContentType = "application/llsd+json"; | 77 | // response.ContentType = "application/llsd+json"; |
80 | response.Body.Write(responseData, 0, responseData.Length); | 78 | // response.Body.Write(responseData, 0, responseData.Length); |
81 | } | 79 | // } |
82 | 80 | // | |
83 | /// <summary> | 81 | // /// <summary> |
84 | /// Send LLSD to an HTTP client in application/llsd+xml form | 82 | // /// Send LLSD to an HTTP client in application/llsd+xml form |
85 | /// </summary> | 83 | // /// </summary> |
86 | /// <param name="response">HTTP response to send the data in</param> | 84 | // /// <param name="response">HTTP response to send the data in</param> |
87 | /// <param name="body">LLSD to send to the client</param> | 85 | // /// <param name="body">LLSD to send to the client</param> |
88 | public static void SendXMLResponse(OSHttpResponse response, OSDMap body) | 86 | // public static void SendXMLResponse(OSHttpResponse response, OSDMap body) |
89 | { | 87 | // { |
90 | byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); | 88 | // byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); |
91 | 89 | // | |
92 | response.ContentEncoding = Encoding.UTF8; | 90 | // response.ContentEncoding = Encoding.UTF8; |
93 | response.ContentLength = responseData.Length; | 91 | // response.ContentLength = responseData.Length; |
94 | response.ContentType = "application/llsd+xml"; | 92 | // response.ContentType = "application/llsd+xml"; |
95 | response.Body.Write(responseData, 0, responseData.Length); | 93 | // response.Body.Write(responseData, 0, responseData.Length); |
96 | } | 94 | // } |
97 | 95 | ||
98 | /// <summary> | 96 | /// <summary> |
99 | /// Make a GET or GET-like request to a web service that returns LLSD | 97 | /// Make a GET or GET-like request to a web service that returns LLSD |