From 8a0a78cbccce796addacab7ed1609279b802a9b3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 20:24:21 +0100 Subject: Make OpenSim.Framework.Servers.HttpServer rely on OpenSim.Framework instead of the other way around. This is necessary so that code in HttpServer can use framework facilities such as the thread watchdog for monitoring purposes. Doing this shuffle meant that MainServer was moved into OpenSim/Framework/Servers Also had to make OpenSim.Framework.Console rely on OpenSim.Framework rather than the other way around since it in turn relies on HttpServer MainConsole and some new interfaces had to be moved into OpenSim/Framework to allow this. This can be reverted if parts of OpenSim.Framework stop relying on console presence (cheifly RegionInfo) --- OpenSim/ConsoleClient/ConsoleClient.cs | 1 + OpenSim/Framework/ConfigurationMember.cs | 2 +- OpenSim/Framework/Console/CommandConsole.cs | 11 +- OpenSim/Framework/Console/ConsoleBase.cs | 2 +- OpenSim/Framework/Console/MainConsole.cs | 40 ------- OpenSim/Framework/ICommandConsole.cs | 90 +++++++++++++++ OpenSim/Framework/IConsole.cs | 53 +++++++++ OpenSim/Framework/IScene.cs | 4 +- OpenSim/Framework/MainConsole.cs | 40 +++++++ OpenSim/Framework/MainServer.cs | 81 ------------- OpenSim/Framework/RegionInfo.cs | 2 +- .../Servers/HttpServer/Interfaces/IHttpServer.cs | 4 +- .../HttpServer/PollServiceRequestManager.cs | 38 ++++--- .../Servers/HttpServer/PollServiceWorkerThread.cs | 2 +- OpenSim/Framework/Servers/MainServer.cs | 81 +++++++++++++ OpenSim/Framework/WebUtil.cs | 60 +++++----- OpenSim/Region/Application/OpenSim.cs | 1 + .../Caps/EventQueue/Tests/EventQueueTests.cs | 1 + .../CoreModules/Avatar/Dialog/DialogModule.cs | 2 +- .../CoreModules/Avatar/Friends/FriendsModule.cs | 1 + .../InstantMessage/HGMessageTransferModule.cs | 1 + .../Avatar/InstantMessage/MessageTransferModule.cs | 1 + .../Framework/Caps/CapabilitiesModule.cs | 1 + .../Framework/Monitoring/MonitorModule.cs | 1 + OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | 1 + .../InterGrid/OpenGridProtocolModule.cs | 1 + .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 1 + .../Asset/AssetServiceInConnectorModule.cs | 1 + .../AuthenticationServiceInConnectorModule.cs | 1 + .../Grid/GridInfoServiceInConnectorModule.cs | 1 + .../Hypergrid/HypergridServiceInConnectorModule.cs | 1 + .../Inventory/InventoryServiceInConnectorModule.cs | 3 +- .../Land/LandServiceInConnectorModule.cs | 1 + .../Login/LLLoginServiceInConnectorModule.cs | 1 + .../MapImage/MapImageServiceInConnectorModule.cs | 1 + .../Neighbour/NeighbourServiceInConnectorModule.cs | 1 + .../SimulationServiceInConnectorModule.cs | 1 + .../Scenes/Tests/ScenePresenceTeleportTests.cs | 1 + .../OptionalModules/Avatar/Chat/IRCBridgeModule.cs | 1 + .../FreeswitchServiceInConnectorModule.cs | 1 + .../World/MoneyModule/SampleMoneyModule.cs | 2 +- .../World/WorldView/WorldViewModule.cs | 1 + OpenSim/Server/Base/HttpServerBase.cs | 1 + OpenSim/Server/Base/ServicesServerBase.cs | 3 +- OpenSim/Tools/pCampBot/pCampBot.cs | 1 + prebuild.xml | 126 +++++++++++---------- 46 files changed, 425 insertions(+), 247 deletions(-) delete mode 100644 OpenSim/Framework/Console/MainConsole.cs create mode 100644 OpenSim/Framework/ICommandConsole.cs create mode 100644 OpenSim/Framework/IConsole.cs create mode 100644 OpenSim/Framework/MainConsole.cs delete mode 100644 OpenSim/Framework/MainServer.cs create mode 100644 OpenSim/Framework/Servers/MainServer.cs diff --git a/OpenSim/ConsoleClient/ConsoleClient.cs b/OpenSim/ConsoleClient/ConsoleClient.cs index f4605da..7c003ea 100644 --- a/OpenSim/ConsoleClient/ConsoleClient.cs +++ b/OpenSim/ConsoleClient/ConsoleClient.cs @@ -33,6 +33,7 @@ using System.IO; using System.Xml; using System.Collections.Generic; using OpenSim.Server.Base; +using OpenSim.Framework; using OpenSim.Framework.Console; using OpenMetaverse; 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; using System.Xml; using log4net; using OpenMetaverse; -using OpenSim.Framework.Console; +//using OpenSim.Framework.Console; namespace OpenSim.Framework { 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; using System.Text; using System.Threading; using log4net; +using OpenSim.Framework; namespace OpenSim.Framework.Console { - public delegate void CommandDelegate(string module, string[] cmd); - - public class Commands + public class Commands : ICommands { /// /// Encapsulates a command that can be invoked from the console @@ -564,14 +563,16 @@ namespace OpenSim.Framework.Console /// /// A console that processes commands internally /// - public class CommandConsole : ConsoleBase + public class CommandConsole : ConsoleBase, ICommandConsole { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public Commands Commands = new Commands(); + public ICommands Commands { get; private set; } public CommandConsole(string defaultPrompt) : base(defaultPrompt) { + Commands = new Commands(); + Commands.AddCommand("console", false, "help", "help []", "Get general command list or more detailed help on a specific command", Help); } 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 protected string prompt = "# "; - public object ConsoleScene = null; + public object ConsoleScene { get; set; } /// /// The default prompt text. diff --git a/OpenSim/Framework/Console/MainConsole.cs b/OpenSim/Framework/Console/MainConsole.cs deleted file mode 100644 index 24be617..0000000 --- a/OpenSim/Framework/Console/MainConsole.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -namespace OpenSim.Framework.Console -{ - public class MainConsole - { - private static CommandConsole instance; - - public static CommandConsole Instance - { - get { return instance; } - set { instance = value; } - } - } -} 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 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Xml; + +namespace OpenSim.Framework +{ + public delegate void CommandDelegate(string module, string[] cmd); + + public interface ICommands + { + void FromXml(XmlElement root, CommandDelegate fn); + + /// + /// Get help for the given help string + /// + /// Parsed parts of the help string. If empty then general help is returned. + /// + List GetHelp(string[] cmd); + + /// + /// Add a command to those which can be invoked from the console. + /// + /// + /// + /// + /// + /// + void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn); + + /// + /// Add a command to those which can be invoked from the console. + /// + /// + /// + /// + /// + /// + /// + void AddCommand(string module, bool shared, string command, + string help, string longhelp, string descriptivehelp, + CommandDelegate fn); + + string[] FindNextOption(string[] cmd, bool term); + + string[] Resolve(string[] cmd); + + XmlElement GetXml(XmlDocument doc); + } + + public interface ICommandConsole : IConsole + { + ICommands Commands { get; } + + /// + /// Display a command prompt on the console and wait for user input + /// + void Prompt(); + + void RunCommand(string cmd); + + string ReadLine(string p, bool isCommand, bool e); + } +} \ 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 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; + +namespace OpenSim.Framework +{ + public interface IConsole + { + object ConsoleScene { get; } + + void Output(string text, string level); + void Output(string text); + void OutputFormat(string format, params object[] components); + + string CmdPrompt(string p); + string CmdPrompt(string p, string def); + string CmdPrompt(string p, List excludedCharacters); + string CmdPrompt(string p, string def, List excludedCharacters); + + // Displays a command prompt and returns a default value, user may only enter 1 of 2 options + string CmdPrompt(string prompt, string defaultresponse, List options); + + // Displays a prompt and waits for the user to enter a string, then returns that string + // (Done with no echo and suitable for passwords) + string PasswdPrompt(string p); + } +} \ 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 @@ */ using OpenMetaverse; -using OpenSim.Framework.Console; +//using OpenSim.Framework.Console; using Nini.Config; namespace OpenSim.Framework @@ -108,7 +108,7 @@ namespace OpenSim.Framework void RegisterModuleInterface(M mod); void StackModuleInterface(M mod); - void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); +// void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); ISceneObject DeserializeObject(string representation); diff --git a/OpenSim/Framework/MainConsole.cs b/OpenSim/Framework/MainConsole.cs new file mode 100644 index 0000000..4527b68 --- /dev/null +++ b/OpenSim/Framework/MainConsole.cs @@ -0,0 +1,40 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OpenSim.Framework +{ + public class MainConsole + { + private static ICommandConsole instance; + + public static ICommandConsole Instance + { + get { return instance; } + set { instance = value; } + } + } +} diff --git a/OpenSim/Framework/MainServer.cs b/OpenSim/Framework/MainServer.cs deleted file mode 100644 index a3e0a26..0000000 --- a/OpenSim/Framework/MainServer.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; -using System.Reflection; -using System.Net; -using log4net; -using OpenSim.Framework.Servers.HttpServer; - -namespace OpenSim.Framework -{ - public class MainServer - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private static BaseHttpServer instance = null; - private static Dictionary m_Servers = - new Dictionary(); - - public static BaseHttpServer Instance - { - get { return instance; } - set { instance = value; } - } - - public static IHttpServer GetHttpServer(uint port) - { - return GetHttpServer(port,null); - } - - public static void AddHttpServer(BaseHttpServer server) - { - m_Servers.Add(server.Port, server); - } - - public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr) - { - if (port == 0) - return Instance; - if (instance != null && port == Instance.Port) - return Instance; - - if (m_Servers.ContainsKey(port)) - return m_Servers[port]; - - m_Servers[port] = new BaseHttpServer(port); - - if (ipaddr != null) - m_Servers[port].ListenIPAddress = ipaddr; - - m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port); - m_Servers[port].Start(); - - return m_Servers[port]; - } - } -} diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 0e41535..f7c080f 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -36,7 +36,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenMetaverse.StructuredData; -using OpenSim.Framework.Console; +//using OpenSim.Framework.Console; namespace OpenSim.Framework { 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 /// /// Add a handler for an HTTP request. /// - /// + /// /// This handler can actually be invoked either as /// /// http://:/?method= @@ -70,7 +70,7 @@ namespace OpenSim.Framework.Servers.HttpServer /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request /// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then /// the "/myapp/" handler is invoked if no "/myapp/page" handler exists. - /// + /// /// /// /// diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 0840a9d..ea30b9a 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -31,6 +31,7 @@ using System.Threading; using System.Reflection; using log4net; using HttpServer; +using OpenSim.Framework; namespace OpenSim.Framework.Servers.HttpServer { @@ -54,21 +55,25 @@ namespace OpenSim.Framework.Servers.HttpServer m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; //startup worker threads - for (uint i=0;i 0; tc++) { //Loop over number of requests each thread handles. - for (int i=0;i 0;i++) + for (int i = 0; i < reqperthread && m_requests.Count > 0; i++) { try { @@ -125,14 +131,14 @@ namespace OpenSim.Framework.Servers.HttpServer } - - ~PollServiceRequestManager() { foreach (object o in m_requests) { PollServiceHttpRequest req = (PollServiceHttpRequest) o; - m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + m_server.DoHTTPGruntWork( + req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); } m_requests.Clear(); @@ -144,4 +150,4 @@ namespace OpenSim.Framework.Servers.HttpServer m_running = false; } } -} +} \ 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 m_timeout = pTimeout; } - public void ThreadStart(object o) + public void ThreadStart() { Run(); } diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs new file mode 100644 index 0000000..b8ab8d9 --- /dev/null +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -0,0 +1,81 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using System.Reflection; +using System.Net; +using log4net; +using OpenSim.Framework.Servers.HttpServer; + +namespace OpenSim.Framework.Servers +{ + public class MainServer + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static BaseHttpServer instance = null; + private static Dictionary m_Servers = + new Dictionary(); + + public static BaseHttpServer Instance + { + get { return instance; } + set { instance = value; } + } + + public static IHttpServer GetHttpServer(uint port) + { + return GetHttpServer(port,null); + } + + public static void AddHttpServer(BaseHttpServer server) + { + m_Servers.Add(server.Port, server); + } + + public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr) + { + if (port == 0) + return Instance; + if (instance != null && port == Instance.Port) + return Instance; + + if (m_Servers.ContainsKey(port)) + return m_Servers[port]; + + m_Servers[port] = new BaseHttpServer(port); + + if (ipaddr != null) + m_Servers[port].ListenIPAddress = ipaddr; + + m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port); + m_Servers[port].Start(); + + return m_Servers[port]; + } + } +} diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index be7504f..cafa441 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -39,9 +39,7 @@ using System.Text; using System.Web; using System.Xml; using System.Xml.Serialization; - using log4net; -using OpenSim.Framework.Servers.HttpServer; using OpenMetaverse.StructuredData; namespace OpenSim.Framework @@ -65,35 +63,35 @@ namespace OpenSim.Framework // a "long" call for warning & debugging purposes public const int LongCallTime = 500; - /// - /// Send LLSD to an HTTP client in application/llsd+json form - /// - /// HTTP response to send the data in - /// LLSD to send to the client - public static void SendJSONResponse(OSHttpResponse response, OSDMap body) - { - byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); - - response.ContentEncoding = Encoding.UTF8; - response.ContentLength = responseData.Length; - response.ContentType = "application/llsd+json"; - response.Body.Write(responseData, 0, responseData.Length); - } - - /// - /// Send LLSD to an HTTP client in application/llsd+xml form - /// - /// HTTP response to send the data in - /// LLSD to send to the client - public static void SendXMLResponse(OSHttpResponse response, OSDMap body) - { - byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); - - response.ContentEncoding = Encoding.UTF8; - response.ContentLength = responseData.Length; - response.ContentType = "application/llsd+xml"; - response.Body.Write(responseData, 0, responseData.Length); - } +// /// +// /// Send LLSD to an HTTP client in application/llsd+json form +// /// +// /// HTTP response to send the data in +// /// LLSD to send to the client +// public static void SendJSONResponse(OSHttpResponse response, OSDMap body) +// { +// byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); +// +// response.ContentEncoding = Encoding.UTF8; +// response.ContentLength = responseData.Length; +// response.ContentType = "application/llsd+json"; +// response.Body.Write(responseData, 0, responseData.Length); +// } +// +// /// +// /// Send LLSD to an HTTP client in application/llsd+xml form +// /// +// /// HTTP response to send the data in +// /// LLSD to send to the client +// public static void SendXMLResponse(OSHttpResponse response, OSDMap body) +// { +// byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); +// +// response.ContentEncoding = Encoding.UTF8; +// response.ContentLength = responseData.Length; +// response.ContentType = "application/llsd+xml"; +// response.Body.Write(responseData, 0, responseData.Length); +// } /// /// Make a GET or GET-like request to a web service that returns LLSD diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index eea008b..7087cb0 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -37,6 +37,7 @@ using Nini.Config; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; using OpenSim.Framework.Statistics; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 2ca02c5..a5209b7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -34,6 +34,7 @@ using NUnit.Framework; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.ClientStack.Linden; using OpenSim.Region.CoreModules.Framework; diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 36fe040..d2a0860 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -201,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog } else { - OpenSim.Framework.Console.MainConsole.Instance.Output( + MainConsole.Instance.Output( "Usage: alert | alert-user "); return; } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 3a7178c..1da9aab 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -36,6 +36,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index eb14603..72b448b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -36,6 +36,7 @@ using Nwc.XmlRpc; using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 77c7147..45b84f4 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -34,6 +34,7 @@ using Nini.Config; using Nwc.XmlRpc; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index eb776fe..afbd902 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs @@ -35,6 +35,7 @@ using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Caps=OpenSim.Framework.Capabilities.Caps; diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index a75d94a..3f466be 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -33,6 +33,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts; using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; using OpenSim.Region.Framework.Interfaces; diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs index b7d3904..2cc0a07 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs @@ -37,6 +37,7 @@ using Nwc.XmlRpc; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index 07999d1..f367739 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs @@ -40,6 +40,7 @@ using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Caps=OpenSim.Framework.Capabilities.Caps; diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index a552a28..7377ceb 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -34,6 +34,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index 422f394..5541684 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs index 2b5beba..ccf2275 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs index f29c074..0e16e5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs index a5b5637..89abbb2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index 53a8ace..831ea27 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Server.Base; @@ -59,9 +60,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory { m_log.Info("[INVENTORY IN CONNECTOR]: Inventory Service In Connector enabled"); } - } - } public void PostInitialise() diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs index fc64203..c8f45f6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs index f759470..ecdb380 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs index e5af1f4..d38af23 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs @@ -32,6 +32,7 @@ using log4net; using Mono.Addins; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs index 5c32632..3fd89b9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index 86b4926..0a5275d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 39bb43a..c5a76b2 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -32,6 +32,7 @@ using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Tests.Common; diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs index d49a489..913d934 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs @@ -34,6 +34,7 @@ using log4net; using Nini.Config; using Nwc.XmlRpc; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs index 97fa63c..74c5139 100644 --- a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using log4net; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index b84a34d..8fc50ff 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs @@ -36,7 +36,7 @@ using Nwc.XmlRpc; using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; - +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs index cee8851..48c242d 100644 --- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs +++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs @@ -36,6 +36,7 @@ using Nini.Config; using OpenMetaverse; using OpenMetaverse.Imaging; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Server.Base; diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index bb5ce96..d471559 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs @@ -31,6 +31,7 @@ using System.Threading; using System.Reflection; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using log4net; using Nini.Config; diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 2652ff2..36e6665 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -30,6 +30,7 @@ using System.IO; using System.Xml; using System.Threading; using System.Reflection; +using OpenSim.Framework; using OpenSim.Framework.Console; using log4net; using log4net.Config; @@ -208,7 +209,7 @@ namespace OpenSim.Server.Base } else { - consoleAppender.Console = MainConsole.Instance; + consoleAppender.Console = (ConsoleBase)MainConsole.Instance; if (null == consoleAppender.Threshold) consoleAppender.Threshold = Level.All; diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index 002a294..77110bf 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -27,6 +27,7 @@ using System; using Nini.Config; +using OpenSim.Framework; using OpenSim.Framework.Console; namespace pCampBot diff --git a/prebuild.xml b/prebuild.xml index a1d56bc..b9201f7 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -55,122 +55,124 @@ --> - + - ../../../../bin/ + ../../bin/ - ../../../../bin/ + ../../bin/ - ../../../../bin/ + ../../bin/ + - - - - - - - - - - - - - - - - - + - + - ../../../bin/ + ../../bin/ - ../../../bin/ + ../../bin/ - ../../../bin/ + ../../bin/ + + + - - - - + + + + + + + + + + - + + - + - ../../bin/ + ../../../../bin/ - ../../bin/ + ../../../../bin/ - ../../bin/ + ../../../../bin/ - + + + + + + + - + + + + + + + + + + + - + - ../../bin/ + ../../../bin/ - ../../bin/ + ../../../bin/ - ../../bin/ + ../../../bin/ - - - - - - - - + + + - - - - + - - + @@ -810,6 +812,7 @@ + @@ -1474,21 +1477,21 @@ + - + + + + + + - - - - - - @@ -3090,6 +3093,7 @@ + -- cgit v1.1 From 968cae6c17fab8aa8a15bfd8231b50873aa6e794 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 20:49:46 +0100 Subject: Add "threads abort " simulator console command that allows us to abort a watchdog managed thread. This is for diagnostic purposes. --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 25 +++++++++++++++++++++++++ OpenSim/Framework/Watchdog.cs | 25 +++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 688be3f..b242e1c 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -192,6 +192,10 @@ namespace OpenSim.Framework.Servers m_console.Commands.AddCommand("base", false, "show version", "show version", "Show server version", HandleShow); + + m_console.Commands.AddCommand("base", false, "threads abort", + "threads abort ", + "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); } } @@ -395,6 +399,27 @@ namespace OpenSim.Framework.Servers break; } } + + public virtual void HandleThreadsAbort(string module, string[] cmd) + { + if (cmd.Length != 3) + { + MainConsole.Instance.Output("Usage: threads abort "); + return; + } + + int threadId; + if (!int.TryParse(cmd[2], out threadId)) + { + MainConsole.Instance.Output("ERROR: Thread id must be an integer"); + return; + } + + if (Watchdog.AbortThread(threadId)) + MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); + else + MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); + } protected void ShowInfo() { diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index 0f34e83..c947ea6 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs @@ -112,8 +112,10 @@ namespace OpenSim.Framework /// /// Stops watchdog tracking on the current thread /// - /// True if the thread was removed from the list of tracked - /// threads, otherwise false + /// + /// True if the thread was removed from the list of tracked + /// threads, otherwise false + /// public static bool RemoveThread() { return RemoveThread(Thread.CurrentThread.ManagedThreadId); @@ -133,6 +135,25 @@ namespace OpenSim.Framework return m_threads.Remove(threadID); } + public static bool AbortThread(int threadID) + { + lock (m_threads) + { + if (m_threads.ContainsKey(threadID)) + { + ThreadWatchdogInfo twi = m_threads[threadID]; + twi.Thread.Abort(); + RemoveThread(threadID); + + return true; + } + else + { + return false; + } + } + } + private static void UpdateThread(int threadID) { ThreadWatchdogInfo threadInfo; -- cgit v1.1 From a4d4f548489e42c98ac3045b032c046fe461aa5b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 20:59:27 +0100 Subject: minor: add "threads show" as synonym for "show threads" for consistency --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index b242e1c..3d20080 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -196,6 +196,11 @@ namespace OpenSim.Framework.Servers m_console.Commands.AddCommand("base", false, "threads abort", "threads abort ", "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); + + m_console.Commands.AddCommand("base", false, "threads show", + "threads show", + "Show thread status. Synonym for \"show threads\"", + (string module, string[] args) => Notice(GetThreadsReport())); } } -- cgit v1.1 From ee4c4e5058cd6a01f45aedf13459e677a4dd001f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 21:03:41 +0100 Subject: Add new LindenCaps test dll to panda run as well as "nant test" --- .nant/local.include | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.nant/local.include b/.nant/local.include index 955c2e5..698af3f 100644 --- a/.nant/local.include +++ b/.nant/local.include @@ -303,6 +303,11 @@ + + + + + -- cgit v1.1 From 1fbb3795367185da534938c4c90e8558795fba88 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 21:15:37 +0100 Subject: minor: rename a parameter in OdeScene.Simulate() from actor -> prim since it's an OdePrim --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 0810ae0..2b29ce4 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -2859,14 +2859,14 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); { //if (timeStep < 0.2f) { - foreach (OdePrim actor in _activeprims) + foreach (OdePrim prim in _activeprims) { - if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag)) + if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag)) { - actor.UpdatePositionAndVelocity(); + prim.UpdatePositionAndVelocity(); if (SupportsNINJAJoints) - SimulateActorPendingJoints(actor); + SimulateActorPendingJoints(prim); } } } -- cgit v1.1 From 7b6b36cee930c61c5d760bbf6089b90567401468 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 21:38:02 +0100 Subject: Fix bug where collision event listeners were not removed once the listener had gone away. This was causing continuous use of temporary memory even when all avatars had left the scene. Memory does leak but it does cause more calls to the garbage collector, which would pause the scene thread for a very short while during collection. --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 2b29ce4..c3279c6 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -1633,6 +1633,8 @@ namespace OpenSim.Region.Physics.OdePlugin /// internal void AddCollisionEventReporting(PhysicsActor obj) { +// m_log.DebugFormat("[PHYSICS]: Adding {0} to collision event reporting", obj.SOPName); + lock (_collisionEventPrim) { if (!_collisionEventPrim.Contains(obj)) @@ -1646,11 +1648,10 @@ namespace OpenSim.Region.Physics.OdePlugin /// internal void RemoveCollisionEventReporting(PhysicsActor obj) { +// m_log.DebugFormat("[PHYSICS]: Removing {0} from collision event reporting", obj.SOPName); + lock (_collisionEventPrim) - { - if (!_collisionEventPrim.Contains(obj)) - _collisionEventPrim.Remove(obj); - } + _collisionEventPrim.Remove(obj); } #region Add/Remove Entities -- cgit v1.1 From 5d37f0471ea504b1426536987d05c7d64dd199ae Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 22:19:17 +0100 Subject: For ScenePresence collision events, instead of creating a new CollisionEventsThisFrame every time we need to send some new ones, reuse the existing one instead. This assumes that the listener is using the data synchronously, which is currently the case. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 ++++++---- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 8 ++++++++ OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 8 +++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c25c3b4..bee96d1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2248,6 +2248,7 @@ namespace OpenSim.Region.Framework.Scenes }); } } + if (colliding.Count > 0) { StartCollidingMessage.Colliders = colliding; @@ -2255,10 +2256,11 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentGroup.Scene == null) return; - if (m_parentGroup.PassCollision == true) - { - //TODO: Add pass to root prim! - } +// if (m_parentGroup.PassCollision == true) +// { +// //TODO: Add pass to root prim! +// } + m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage); } } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 96dcfb6..1659ebd 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -113,6 +113,14 @@ namespace OpenSim.Region.Physics.Manager m_objCollisionList[localID] = contact; } } + + /// + /// Clear added collision events. + /// + public void Clear() + { + m_objCollisionList.Clear(); + } } public abstract class PhysicsActor diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index e9bab66..55e14bc 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1235,11 +1235,9 @@ namespace OpenSim.Region.Physics.OdePlugin { if (m_eventsubscription > m_requestedUpdateFrequency) { - if (CollisionEventsThisFrame != null) - { - base.SendCollisionUpdate(CollisionEventsThisFrame); - } - CollisionEventsThisFrame = new CollisionEventUpdate(); + base.SendCollisionUpdate(CollisionEventsThisFrame); + + CollisionEventsThisFrame.Clear(); m_eventsubscription = 0; } } -- cgit v1.1 From b9f106f484e3b80c4572f10e81c20da254b5cbae Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 22:28:40 +0100 Subject: When sending object collision updates, don't null out and recreate the CollisionEventUpdate() if the number of collisions falls to zero. Reuse the existing one instead. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 5 +++++ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 16 +++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 1659ebd..44af636 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -70,6 +70,11 @@ namespace OpenSim.Region.Physics.Manager { // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. + /// + /// Number of collision events in this update. + /// + public int Count { get { return m_objCollisionList.Count; } } + public int m_colliderType; public int m_GenericStartEnd; //public uint m_LocalID; diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 3087f8d..4ef731d 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -191,7 +191,7 @@ namespace OpenSim.Region.Physics.OdePlugin private d.Mass pMass; private int m_eventsubscription; - private CollisionEventUpdate CollisionEventsThisFrame; + private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); private IntPtr m_linkJoint = IntPtr.Zero; @@ -3020,23 +3020,13 @@ Console.WriteLine(" JointCreateFixed"); public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { - if (CollisionEventsThisFrame == null) - CollisionEventsThisFrame = new CollisionEventUpdate(); - CollisionEventsThisFrame.addCollider(CollidedWith, contact); } public void SendCollisions() { - if (CollisionEventsThisFrame == null) - return; - - base.SendCollisionUpdate(CollisionEventsThisFrame); - - if (CollisionEventsThisFrame.m_objCollisionList.Count == 0) - CollisionEventsThisFrame = null; - else - CollisionEventsThisFrame = new CollisionEventUpdate(); + if (CollisionEventsThisFrame.Count > 0) + base.SendCollisionUpdate(CollisionEventsThisFrame); } public override bool SubscribedEvents() -- cgit v1.1 From c825c9a94588e31c38ba43bf8ea763818e1c02b6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 22:35:00 +0100 Subject: Get rid of the pointless null checks on collision listeners. Add warning about synchronicity for PhysicsActor.OnCollisionUpdate event doc --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 ---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 6 ++++++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index bee96d1..8b68102 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2083,10 +2083,6 @@ namespace OpenSim.Region.Framework.Scenes public void PhysicsCollision(EventArgs e) { // single threaded here - if (e == null) - { - return; - } CollisionEventUpdate a = (CollisionEventUpdate)e; Dictionary collissionswith = a.m_objCollisionList; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e685a2c..ee6c708 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3296,9 +3296,6 @@ namespace OpenSim.Region.Framework.Scenes // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { - if (e == null) - return; - //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 44af636..8f5abde 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -140,7 +140,13 @@ namespace OpenSim.Region.Physics.Manager public event VelocityUpdate OnVelocityUpdate; public event OrientationUpdate OnOrientationUpdate; public event RequestTerseUpdate OnRequestTerseUpdate; + + /// + /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event + /// object is reused in subsequent physics frames. + /// public event CollisionUpdate OnCollisionUpdate; + public event OutOfBounds OnOutOfBounds; #pragma warning restore 67 -- cgit v1.1 From 0f83f87233544972ad6799cb78e5f21845c53fbd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 22:39:08 +0100 Subject: Remove unused fields from CollisionEventUpdate --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 2 +- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 30 +++++----------------- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 +- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 2 +- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 682eb80..9a6857b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -443,7 +443,7 @@ public class BSCharacter : PhysicsActor Dictionary contactPoints = new Dictionary(); contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - CollisionEventUpdate args = new CollisionEventUpdate(LocalID, (int)type, 1, contactPoints); + CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); base.SendCollisionUpdate(args); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index bb8d601..8782e62 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1350,7 +1350,7 @@ public sealed class BSPrim : PhysicsActor // create the event for the collision Dictionary contactPoints = new Dictionary(); contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - CollisionEventUpdate args = new CollisionEventUpdate(LocalID, (int)type, 1, contactPoints); + CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); base.SendCollisionUpdate(args); } } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 8f5abde..362f997 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -66,47 +66,29 @@ namespace OpenSim.Region.Physics.Manager } } + /// + /// Used to pass collision information to OnCollisionUpdate listeners. + /// public class CollisionEventUpdate : EventArgs { - // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. - /// /// Number of collision events in this update. /// public int Count { get { return m_objCollisionList.Count; } } - public int m_colliderType; - public int m_GenericStartEnd; - //public uint m_LocalID; - public Dictionary m_objCollisionList = new Dictionary(); + public Dictionary m_objCollisionList; - public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary objCollisionList) + public CollisionEventUpdate(Dictionary objCollisionList) { - m_colliderType = colliderType; - m_GenericStartEnd = GenericStartEnd; m_objCollisionList = objCollisionList; } public CollisionEventUpdate() { - m_colliderType = (int) ActorTypes.Unknown; - m_GenericStartEnd = 1; m_objCollisionList = new Dictionary(); } - public int collidertype - { - get { return m_colliderType; } - set { m_colliderType = value; } - } - - public int GenericStartEnd - { - get { return m_GenericStartEnd; } - set { m_GenericStartEnd = value; } - } - - public void addCollider(uint localID, ContactPoint contact) + public void AddCollider(uint localID, ContactPoint contact) { if (!m_objCollisionList.ContainsKey(localID)) { diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 55e14bc..b6e1c4e 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1227,7 +1227,7 @@ namespace OpenSim.Region.Physics.OdePlugin // m_log.DebugFormat( // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact); - CollisionEventsThisFrame.addCollider(CollidedWith, contact); + CollisionEventsThisFrame.AddCollider(CollidedWith, contact); } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 4ef731d..0363885 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -3020,7 +3020,7 @@ Console.WriteLine(" JointCreateFixed"); public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { - CollisionEventsThisFrame.addCollider(CollidedWith, contact); + CollisionEventsThisFrame.AddCollider(CollidedWith, contact); } public void SendCollisions() -- cgit v1.1 From 6a74a4c12b769742f9e6ee328fd7557faa826e50 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 22:46:42 +0100 Subject: Clear OdeCharacter CollisionEventUpdate when we subscribe or unsubscribe from collision events --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index b6e1c4e..c22d27f 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1210,11 +1210,13 @@ namespace OpenSim.Region.Physics.OdePlugin { m_requestedUpdateFrequency = ms; m_eventsubscription = ms; + CollisionEventsThisFrame.Clear(); _parent_scene.AddCollisionEventReporting(this); } public override void UnSubscribeEvents() { + CollisionEventsThisFrame.Clear(); _parent_scene.RemoveCollisionEventReporting(this); m_requestedUpdateFrequency = 0; m_eventsubscription = 0; -- cgit v1.1 From e549f2f443bdf1e711d02dbd7d1977e0c296b1df Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 22:51:23 +0100 Subject: Add m_threads dictionary locking to Watchdog.GetThreads() --- OpenSim/Framework/Watchdog.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index c947ea6..3ef9ccb 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs @@ -178,7 +178,8 @@ namespace OpenSim.Framework /// public static ThreadWatchdogInfo[] GetThreads() { - return m_threads.Values.ToArray(); + lock (m_threads) + return m_threads.Values.ToArray(); } private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) -- cgit v1.1 From 182908d216f27861d033f69398abff996caf8053 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 23:16:01 +0100 Subject: In Watchdog, add ability to specific timeout for a thread. This also changes the point of registration to the StartThread() call rather than the first Update() --- OpenSim/Framework/Watchdog.cs | 72 +++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index 3ef9ccb..1374518 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs @@ -40,18 +40,30 @@ namespace OpenSim.Framework { /// Timer interval in milliseconds for the watchdog timer const double WATCHDOG_INTERVAL_MS = 2500.0d; + /// Maximum timeout in milliseconds before a thread is considered dead const int WATCHDOG_TIMEOUT_MS = 5000; [System.Diagnostics.DebuggerDisplay("{Thread.Name}")] public class ThreadWatchdogInfo { - public Thread Thread; - public int LastTick; + public Thread Thread { get; private set; } + public int LastTick { get; set; } + + /// + /// Number of seconds before we notify that the thread is having a problem. + /// + public int Timeout { get; set; } + + /// + /// Is this thread considered timed out? + /// + public bool IsTimedOut { get; set; } - public ThreadWatchdogInfo(Thread thread) + public ThreadWatchdogInfo(Thread thread, int timeout) { Thread = thread; + Timeout = timeout; LastTick = Environment.TickCount & Int32.MaxValue; } } @@ -82,7 +94,7 @@ namespace OpenSim.Framework } /// - /// Start a new thread that is tracked by the watchdog timer + /// Start a new thread that is tracked by the watchdog timer. /// /// The method that will be executed in a new thread /// A name to give to the new thread @@ -92,12 +104,37 @@ namespace OpenSim.Framework /// The newly created Thread object public static Thread StartThread(ThreadStart start, string name, ThreadPriority priority, bool isBackground) { + return StartThread(start, name, priority, isBackground, WATCHDOG_TIMEOUT_MS); + } + + /// + /// Start a new thread that is tracked by the watchdog timer + /// + /// The method that will be executed in a new thread + /// A name to give to the new thread + /// Priority to run the thread at + /// True to run this thread as a background + /// thread, otherwise false + /// + /// Number of seconds to wait until we issue a warning about timeout. + /// + /// The newly created Thread object + public static Thread StartThread( + ThreadStart start, string name, ThreadPriority priority, bool isBackground, int timeout) + { Thread thread = new Thread(start); thread.Name = name; thread.Priority = priority; thread.IsBackground = isBackground; thread.Start(); + ThreadWatchdogInfo twi = new ThreadWatchdogInfo(thread, timeout); + + m_log.Debug("[WATCHDOG]: Started tracking thread \"" + twi.Thread.Name + "\" (ID " + twi.Thread.ManagedThreadId + ")"); + + lock (m_threads) + m_threads.Add(twi.Thread.ManagedThreadId, twi); + return thread; } @@ -121,14 +158,6 @@ namespace OpenSim.Framework return RemoveThread(Thread.CurrentThread.ManagedThreadId); } - private static void AddThread(ThreadWatchdogInfo threadInfo) - { - m_log.Debug("[WATCHDOG]: Started tracking thread \"" + threadInfo.Thread.Name + "\" (ID " + threadInfo.Thread.ManagedThreadId + ")"); - - lock (m_threads) - m_threads.Add(threadInfo.Thread.ManagedThreadId, threadInfo); - } - private static bool RemoveThread(int threadID) { lock (m_threads) @@ -165,9 +194,14 @@ namespace OpenSim.Framework try { if (m_threads.TryGetValue(threadID, out threadInfo)) + { threadInfo.LastTick = Environment.TickCount & Int32.MaxValue; + threadInfo.IsTimedOut = false; + } else - AddThread(new ThreadWatchdogInfo(Thread.CurrentThread)); + { + m_log.WarnFormat("[WATCHDOG]: Asked to update thread {0} which is not being monitored", threadID); + } } catch { } } @@ -196,10 +230,16 @@ namespace OpenSim.Framework foreach (ThreadWatchdogInfo threadInfo in m_threads.Values) { - if (threadInfo.Thread.ThreadState == ThreadState.Stopped || now - threadInfo.LastTick >= WATCHDOG_TIMEOUT_MS) + if (threadInfo.Thread.ThreadState == ThreadState.Stopped) + { + timedOut = threadInfo; + RemoveThread(threadInfo.Thread.ManagedThreadId); + break; + } + else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) { + threadInfo.IsTimedOut = true; timedOut = threadInfo; - m_threads.Remove(threadInfo.Thread.ManagedThreadId); break; } } @@ -212,4 +252,4 @@ namespace OpenSim.Framework m_watchdogTimer.Start(); } } -} +} \ No newline at end of file -- cgit v1.1 From c275c229281c9a7113659457a310da775f26ec43 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 23:26:21 +0100 Subject: Restart the event queue worker threads that I accidentally disabled earlier today in 8a0a78c. Also adds these to the watchdogs with very large timeouts (should really be infinite) --- .../Servers/HttpServer/PollServiceRequestManager.cs | 16 +++++++++------- OpenSim/Framework/Watchdog.cs | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index ea30b9a..d9965b6 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -60,12 +60,13 @@ namespace OpenSim.Framework.Servers.HttpServer m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout); m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent; -// m_workerThreads[i] -// = Watchdog.StartThread( -// m_PollServiceWorkerThreads[i].ThreadStart, -// String.Format("PollServiceWorkerThread{0}", i), -// ThreadPriority.Normal, -// false); + m_workerThreads[i] + = Watchdog.StartThread( + m_PollServiceWorkerThreads[i].ThreadStart, + String.Format("PollServiceWorkerThread{0}", i), + ThreadPriority.Normal, + false, + int.MaxValue); } m_watcherThread @@ -73,7 +74,8 @@ namespace OpenSim.Framework.Servers.HttpServer this.ThreadStart, "PollServiceWatcherThread", ThreadPriority.Normal, - false); + false, + 1000 * 60 * 10); } internal void ReQueueEvent(PollServiceHttpRequest req) diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs index 1374518..5ffa890 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Watchdog.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework public int LastTick { get; set; } /// - /// Number of seconds before we notify that the thread is having a problem. + /// Number of milliseconds before we notify that the thread is having a problem. /// public int Timeout { get; set; } @@ -116,7 +116,7 @@ namespace OpenSim.Framework /// True to run this thread as a background /// thread, otherwise false /// - /// Number of seconds to wait until we issue a warning about timeout. + /// Number of milliseconds to wait until we issue a warning about timeout. /// /// The newly created Thread object public static Thread StartThread( -- cgit v1.1