From 8a0a78cbccce796addacab7ed1609279b802a9b3 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 20:24:21 +0100 Subject: [PATCH 01/18] 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/ICommandConsole.cs | 90 +++++++++++ OpenSim/Framework/IConsole.cs | 53 +++++++ OpenSim/Framework/IScene.cs | 4 +- .../Framework/{Console => }/MainConsole.cs | 6 +- OpenSim/Framework/RegionInfo.cs | 2 +- .../HttpServer/Interfaces/IHttpServer.cs | 4 +- .../HttpServer/PollServiceRequestManager.cs | 38 +++-- .../HttpServer/PollServiceWorkerThread.cs | 2 +- OpenSim/Framework/{ => Servers}/MainServer.cs | 2 +- OpenSim/Framework/WebUtil.cs | 60 ++++--- OpenSim/Region/Application/OpenSim.cs | 1 + .../Caps/EventQueue/Tests/EventQueueTests.cs | 1 + .../CoreModules/Avatar/Dialog/DialogModule.cs | 2 +- .../Avatar/Friends/FriendsModule.cs | 1 + .../InstantMessage/HGMessageTransferModule.cs | 1 + .../InstantMessage/MessageTransferModule.cs | 1 + .../Framework/Caps/CapabilitiesModule.cs | 1 + .../Framework/Monitoring/MonitorModule.cs | 1 + .../Region/CoreModules/InterGrid/OGSRadmin.cs | 1 + .../InterGrid/OpenGridProtocolModule.cs | 1 + .../Scripting/LSLHttp/UrlModule.cs | 1 + .../Asset/AssetServiceInConnectorModule.cs | 1 + .../AuthenticationServiceInConnectorModule.cs | 1 + .../Grid/GridInfoServiceInConnectorModule.cs | 1 + .../HypergridServiceInConnectorModule.cs | 1 + .../InventoryServiceInConnectorModule.cs | 3 +- .../Land/LandServiceInConnectorModule.cs | 1 + .../Login/LLLoginServiceInConnectorModule.cs | 1 + .../MapImageServiceInConnectorModule.cs | 1 + .../NeighbourServiceInConnectorModule.cs | 1 + .../SimulationServiceInConnectorModule.cs | 1 + .../Tests/ScenePresenceTeleportTests.cs | 1 + .../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 | 146 +++++++++--------- 44 files changed, 318 insertions(+), 140 deletions(-) create mode 100644 OpenSim/Framework/ICommandConsole.cs create mode 100644 OpenSim/Framework/IConsole.cs rename OpenSim/Framework/{Console => }/MainConsole.cs (93%) rename OpenSim/Framework/{ => Servers}/MainServer.cs (98%) diff --git a/OpenSim/ConsoleClient/ConsoleClient.cs b/OpenSim/ConsoleClient/ConsoleClient.cs index f4605da0b8..7c003eaf81 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 b4ce8773af..7afa68a79c 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 be36cf2c10..f10b85794d 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 c59fbca074..4b375d9963 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/ICommandConsole.cs b/OpenSim/Framework/ICommandConsole.cs new file mode 100644 index 0000000000..d33b9b5772 --- /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 0000000000..33024b2076 --- /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 e0cb897e40..f1b4732bf0 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/Console/MainConsole.cs b/OpenSim/Framework/MainConsole.cs similarity index 93% rename from OpenSim/Framework/Console/MainConsole.cs rename to OpenSim/Framework/MainConsole.cs index 24be6178db..4527b68a75 100644 --- a/OpenSim/Framework/Console/MainConsole.cs +++ b/OpenSim/Framework/MainConsole.cs @@ -25,13 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -namespace OpenSim.Framework.Console +namespace OpenSim.Framework { public class MainConsole { - private static CommandConsole instance; + private static ICommandConsole instance; - public static CommandConsole Instance + public static ICommandConsole Instance { get { return instance; } set { instance = value; } diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 0e41535851..f7c080fc8b 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 65b1eb5699..fd77984c22 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 0840a9db7d..ea30b9af6c 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 b91496be2a..16e56d2060 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/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs similarity index 98% rename from OpenSim/Framework/MainServer.cs rename to OpenSim/Framework/Servers/MainServer.cs index a3e0a26bb7..b8ab8d9b26 100644 --- a/OpenSim/Framework/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -31,7 +31,7 @@ using System.Net; using log4net; using OpenSim.Framework.Servers.HttpServer; -namespace OpenSim.Framework +namespace OpenSim.Framework.Servers { public class MainServer { diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index be7504f413..cafa441289 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 eea008b163..7087cb0009 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 2ca02c5c57..a5209b7aec 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 36fe040327..d2a0860861 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 3a7178c33a..1da9aabc90 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 eb14603a36..72b448b9d6 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 77c714710f..45b84f4295 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 eb776fe1bb..afbd90205b 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 a75d94adaf..3f466be6fe 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 b7d3904db2..2cc0a0797f 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 07999d16c1..f3677390a9 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 a552a28912..7377ceb0a6 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 422f394d7a..554168499a 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 2b5beba374..ccf22755b9 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 f29c074206..0e16e5ab82 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 a5b5637961..89abbb225b 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 53a8ace14c..831ea27bd1 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 fc642032b5..c8f45f69b9 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 f759470b28..ecdb380209 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 e5af1f4133..d38af23dd1 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 5c3263260e..3fd89b9b24 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 86b4926ac5..0a5275d3d0 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 39bb43a628..c5a76b2683 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 d49a4899ca..913d934cf3 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 97fa63cb45..74c51391c1 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 b84a34d288..8fc50ff883 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 cee8851c3a..48c242db51 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 bb5ce96757..d47155984f 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 2652ff2869..36e66650c2 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 002a294420..77110bf6b8 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 a1d56bcb7a..b9201f7606 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -55,68 +55,6 @@ --> - - - - ../../../../bin/ - - - - - ../../../../bin/ - - - - ../../../../bin/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - ../../../bin/ - - - - - ../../../bin/ - - - - ../../../bin/ - - - - - - - - - - - - @@ -162,8 +100,8 @@ - - + + @@ -174,6 +112,70 @@ + + + + ../../../../bin/ + + + + + ../../../../bin/ + + + + ../../../../bin/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + @@ -810,6 +812,7 @@ + @@ -1474,21 +1477,21 @@ + - + + + + + + - - - - - - @@ -3090,6 +3093,7 @@ + From 968cae6c17fab8aa8a15bfd8231b50873aa6e794 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 20:49:46 +0100 Subject: [PATCH 02/18] Add "threads abort " simulator console command that allows us to abort a watchdog managed thread. This is for diagnostic purposes. --- .../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 688be3f7f1..b242e1c01a 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 0f34e8338d..c947ea6e92 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; From a4d4f548489e42c98ac3045b032c046fe461aa5b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 20:59:27 +0100 Subject: [PATCH 03/18] 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 b242e1c01a..3d2008050b 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())); } } From ee4c4e5058cd6a01f45aedf13459e677a4dd001f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 21:03:41 +0100 Subject: [PATCH 04/18] 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 955c2e53a0..698af3f993 100644 --- a/.nant/local.include +++ b/.nant/local.include @@ -303,6 +303,11 @@ + + + + + From 1fbb3795367185da534938c4c90e8558795fba88 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 21:15:37 +0100 Subject: [PATCH 05/18] 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 0810ae0e0e..2b29ce4ca7 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); } } } From 7b6b36cee930c61c5d760bbf6089b90567401468 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 21:38:02 +0100 Subject: [PATCH 06/18] 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 2b29ce4ca7..c3279c6911 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 From 5d37f0471ea504b1426536987d05c7d64dd199ae Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:19:17 +0100 Subject: [PATCH 07/18] 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 c25c3b4972..bee96d1f29 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 96dcfb6b0a..1659ebd6ef 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 e9bab66320..55e14bc8de 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; } } From b9f106f484e3b80c4572f10e81c20da254b5cbae Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:28:40 +0100 Subject: [PATCH 08/18] 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 1659ebd6ef..44af636df9 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 3087f8d84e..4ef731d5d0 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() From c825c9a94588e31c38ba43bf8ea763818e1c02b6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:35:00 +0100 Subject: [PATCH 09/18] 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 bee96d1f29..8b6810251c 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 e685a2c366..ee6c708d3f 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 44af636df9..8f5abdea30 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 From 0f83f87233544972ad6799cb78e5f21845c53fbd Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:39:08 +0100 Subject: [PATCH 10/18] Remove unused fields from CollisionEventUpdate --- .../Physics/BulletSPlugin/BSCharacter.cs | 2 +- .../Region/Physics/BulletSPlugin/BSPrim.cs | 2 +- .../Region/Physics/Manager/PhysicsActor.cs | 30 ++++--------------- .../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 682eb80234..9a6857bea4 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 bb8d601ad8..8782e6277b 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 8f5abdea30..362f997e18 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 55e14bc8de..b6e1c4ec0b 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 4ef731d5d0..036388538c 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() From 6a74a4c12b769742f9e6ee328fd7557faa826e50 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:46:42 +0100 Subject: [PATCH 11/18] 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 b6e1c4ec0b..c22d27fdff 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; From e549f2f443bdf1e711d02dbd7d1977e0c296b1df Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:51:23 +0100 Subject: [PATCH 12/18] 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 c947ea6e92..3ef9ccbba0 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) From 182908d216f27861d033f69398abff996caf8053 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 23:16:01 +0100 Subject: [PATCH 13/18] 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 3ef9ccbba0..1374518b6e 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; } - public ThreadWatchdogInfo(Thread thread) + /// + /// 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, 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 @@ -91,6 +103,24 @@ namespace OpenSim.Framework /// thread, otherwise false /// 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; @@ -98,6 +128,13 @@ namespace OpenSim.Framework 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; - m_threads.Remove(threadInfo.Thread.ManagedThreadId); + RemoveThread(threadInfo.Thread.ManagedThreadId); + break; + } + else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) + { + threadInfo.IsTimedOut = true; + timedOut = threadInfo; break; } } @@ -212,4 +252,4 @@ namespace OpenSim.Framework m_watchdogTimer.Start(); } } -} +} \ No newline at end of file From c275c229281c9a7113659457a310da775f26ec43 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 23:26:21 +0100 Subject: [PATCH 14/18] 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) --- .../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 ea30b9af6c..d9965b6a64 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 1374518b6e..5ffa8909e6 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( From 059f4b6a3a870fdbb246ed2a4109cbf28b58ca7d Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Tue, 25 Oct 2011 13:27:09 +0100 Subject: [PATCH 15/18] Implementing PRIM_LINK_TARGET, but only for setting params Signed-off-by: BlueWall --- .../Shared/Api/Implementation/LSL_Api.cs | 17 +++++++++++++---- .../Shared/Api/Runtime/LSL_Constants.cs | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b8e98784ca..fe8d358bae 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7014,10 +7014,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - List parts = GetLinkParts(linknumber); - - foreach (SceneObjectPart part in parts) - SetPrimParams(part, rules); + setLinkPrimParams(linknumber, rules); ScriptSleep(200); } @@ -7026,6 +7023,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + setLinkPrimParams(linknumber, rules); + } + + protected void setLinkPrimParams(int linknumber, LSL_List rules) + { List parts = GetLinkParts(linknumber); foreach (SceneObjectPart part in parts) @@ -7395,6 +7397,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return; + LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); + LSL_List new_rules = rules.GetSublist(idx, -1); + setLinkPrimParams((int)new_linknumber, new_rules); + return; } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 4b008a449e..50c18a8d57 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -321,6 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_NAME = 27; public const int PRIM_DESC = 28; public const int PRIM_ROT_LOCAL = 29; + public const int PRIM_LINK_TARGET = 34; public const int PRIM_TEXGEN_DEFAULT = 0; public const int PRIM_TEXGEN_PLANAR = 1; From 66bdd2062812c5f2a3223395691df8c1034b8229 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 26 Oct 2011 08:33:17 -0400 Subject: [PATCH 16/18] Add some things to .gitignore to make the status cleaner --- .gitignore | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8d3f2b266f..0fd1e586cf 100644 --- a/.gitignore +++ b/.gitignore @@ -70,4 +70,20 @@ TAGS Makefile.local bin/.version compile.bat - +addon-modules +OpenSim/Data/Tests/test-results/ +OpenSim/Framework/Serialization/Tests/test-results/ +OpenSim/Framework/Servers/Tests/test-results/ +OpenSim/Framework/Tests/test-results/ +OpenSim/Region/ClientStack/Linden/Caps/test-results/ +OpenSim/Region/ClientStack/Linden/UDP/Tests/test-results/ +OpenSim/Region/CoreModules/test-results/ +OpenSim/Region/Framework/test-results/ +OpenSim/Region/OptionalModules/test-results/ +OpenSim/Region/Physics/BulletDotNETPlugin/ +OpenSim/Region/Physics/Manager/test-results/ +OpenSim/Region/Physics/OdePlugin/Tests/test-results/ +OpenSim/Region/ScriptEngine/test-results/ +OpenSim/Tests/Common/test-results/ +OpenSim/Tests/test-results/ +test-results/ From 9a28e7a4e0392ef0a5b890b4c1875a44af57a90c Mon Sep 17 00:00:00 2001 From: SignpostMarv Martin Date: Wed, 26 Oct 2011 13:33:52 +0100 Subject: [PATCH 17/18] Implementation of PRIM_OMEGA, but only for setting Signed-off-by: BlueWall --- .../Shared/Api/Implementation/LSL_Api.cs | 21 +++++++++++++++---- .../Shared/Api/Runtime/LSL_Constants.cs | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fe8d358bae..82701ce636 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3325,12 +3325,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) { m_host.AddScriptLPS(1); - m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); - m_host.ScheduleTerseUpdate(); - m_host.SendTerseUpdateToAllClients(); - m_host.ParentGroup.HasGroupChanged = true; + TargetOmega(m_host, axis, spinrate, gain); } + protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) + { + part.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); + part.ScheduleTerseUpdate(); + part.SendTerseUpdateToAllClients(); + part.ParentGroup.HasGroupChanged = true; + } + public LSL_Integer llGetStartParameter() { m_host.AddScriptLPS(1); @@ -7397,6 +7402,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; + case (int)ScriptBaseClass.PRIM_OMEGA: + if (remain < 3) + return; + LSL_Vector axis = rules.GetVector3Item(idx++); + LSL_Float spinrate = rules.GetLSLFloatItem(idx++); + LSL_Float gain = rules.GetLSLFloatItem(idx++); + TargetOmega(part, axis, (double)spinrate, (double)gain); + break; case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 50c18a8d57..ce4661cf65 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -321,6 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_NAME = 27; public const int PRIM_DESC = 28; public const int PRIM_ROT_LOCAL = 29; + public const int PRIM_OMEGA = 32; public const int PRIM_LINK_TARGET = 34; public const int PRIM_TEXGEN_DEFAULT = 0; public const int PRIM_TEXGEN_PLANAR = 1; From 41395d544386fbee2d26909a590d4fa9720fdf5f Mon Sep 17 00:00:00 2001 From: Michelle Argus Date: Wed, 26 Oct 2011 15:03:10 +0200 Subject: [PATCH 18/18] Added optional owner classes to existing OSSL agent Permissions PARCEL_GROUP, PARCEL_OWNER, ESTATE_MANAGER and REGION_OWNER can be combined with the existing agent uuid option to limit ossl functions to agents and owner classes. Signed-off-by: BlueWall --- .../Shared/Api/Implementation/OSSL_Api.cs | 67 +++++++++++++++++-- bin/OpenSim.ini.example | 7 ++ bin/OpenSimDefaults.ini | 7 ++ 3 files changed, 75 insertions(+), 6 deletions(-) mode change 100644 => 100755 bin/OpenSim.ini.example diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 52d787db0c..3cfc3c94f1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -113,11 +113,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { public List AllowedCreators; public List AllowedOwners; + public List AllowedOwnerClasses; public FunctionPerms() { AllowedCreators = new List(); AllowedOwners = new List(); + AllowedOwnerClasses = new List(); } } @@ -245,6 +247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Default behavior perms.AllowedOwners = null; perms.AllowedCreators = null; + perms.AllowedOwnerClasses = null; } else { @@ -265,12 +268,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api foreach (string id in ids) { string current = id.Trim(); - UUID uuid; - - if (UUID.TryParse(current, out uuid)) + if (current.ToUpper() == "PARCEL_GROUP_MEMBER" || current.ToUpper() == "PARCEL_OWNER" || current.ToUpper() == "ESTATE_MANAGER" || current.ToUpper() == "ESTATE_OWNER") { - if (uuid != UUID.Zero) - perms.AllowedOwners.Add(uuid); + if (!perms.AllowedOwnerClasses.Contains(current)) + perms.AllowedOwnerClasses.Add(current.ToUpper()); + } + else + { + UUID uuid; + + if (UUID.TryParse(current, out uuid)) + { + if (uuid != UUID.Zero) + perms.AllowedOwners.Add(uuid); + } } } @@ -326,11 +337,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api String.Format("{0} permission error. Can't find script in prim inventory.", function)); } + + UUID ownerID = ti.OwnerID; + + //OSSL only may be used if objet is in the same group as the parcel + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) + { + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + + if (land.LandData.GroupID == ti.GroupID && land.LandData.GroupID != UUID.Zero) + { + return; + } + } + + //Only Parcelowners may use the function + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_OWNER")) + { + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + + if (land.LandData.OwnerID == ownerID) + { + return; + } + } + + //Only Estate Managers may use the function + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) + { + //Only Estate Managers may use the function + if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) + { + return; + } + } + + //Only regionowners may use the function + if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_OWNER")) + { + if (World.RegionInfo.EstateSettings.EstateOwner == ownerID) + { + return; + } + } + if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID)) OSSLError( String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", function)); - if (ti.CreatorID != ti.OwnerID) + if (ti.CreatorID != ownerID) { if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0) OSSLError( diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example old mode 100644 new mode 100755 index 44da31cb86..80f4c0ed92 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -617,6 +617,13 @@ ; Comma separated list of UUIDS allows the function for that list of UUIDS ; Allow_osSetRegionWaterHeight = 888760cb-a3cf-43ac-8ea4-8732fd3ee2bb + + ; Comma separated list of owner classes that allow the function for a particular class of owners. Choices are + ; - PARCEL_GROUP_MEMBER: allow if objectgroup is the same group as the parcel + ; - PARCEL_OWNER: allow if the objectowner is parcelowner + ; - ESTATE_MANAGER: allow if the object owner is a estate manager + ; - ESTATE_OWNER: allow if objectowner is estateowner + ; Allow_osSetRegionWaterHeight = 888760cb-a3cf-43ac-8ea4-8732fd3ee2bb, PARCEL_OWNER, ESTATE_OWNER>, ... ; You can also use script creators as the uuid ; Creators_osSetRegionWaterHeight = , ... diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 7df4357800..16ce1256aa 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1196,6 +1196,13 @@ ; Comma separated list of UUIDS allows the function for that list of UUIDS ; Allow_osSetRegionWaterHeight = 888760cb-a3cf-43ac-8ea4-8732fd3ee2bb + + ; Comma separated list of owner classes that allow the function for a particular class of owners. Choices are + ; - PARCEL_GROUP_MEMBER: allow if objectgroup is the same group as the parcel + ; - PARCEL_OWNER: allow if the objectowner is parcelowner + ; - ESTATE_MANAGER: allow if the object owner is a estate manager + ; - ESTATE_OWNER: allow if objectowner is estateowner + ; Allow_osSetRegionWaterHeight = 888760cb-a3cf-43ac-8ea4-8732fd3ee2bb, PARCEL_OWNER, ESTATE_OWNER>, ... ; You can also use script creators as the uuid ; Creators_osSetRegionWaterHeight = , ...