From e36a54ee2ab7b9e8f9c9170610a942c261eb270c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Oct 2009 20:39:23 -0700 Subject: #if DEBBUG code for monitoring the ThreadPool. --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 606135b..35e57e5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -962,6 +962,13 @@ namespace OpenSim.Region.Framework.Scenes int maintc = 0; while (!shuttingdown) { +#if DEBUG + int w = 0, io = 0, maxw=0, maxio=0; + ThreadPool.GetAvailableThreads(out w, out io); + ThreadPool.GetMaxThreads(out maxw, out maxio); + if ((maxw - w < 10) || (maxio - io < 10)) + m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}({1}); io = {2}({3})", w, io, maxw, maxio); +#endif maintc = Environment.TickCount; TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; -- cgit v1.1 From 0c46df973ad08381a7fcdb892e4525dfdb1d6ee4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Oct 2009 21:02:10 -0700 Subject: Correction on the DEBUG code. --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 35e57e5..d0dc021 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -963,11 +963,10 @@ namespace OpenSim.Region.Framework.Scenes while (!shuttingdown) { #if DEBUG - int w = 0, io = 0, maxw=0, maxio=0; + int w = 0, io = 0; ThreadPool.GetAvailableThreads(out w, out io); - ThreadPool.GetMaxThreads(out maxw, out maxio); - if ((maxw - w < 10) || (maxio - io < 10)) - m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}({1}); io = {2}({3})", w, io, maxw, maxio); + if ((w < 10) || (io < 10)) + m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); #endif maintc = Environment.TickCount; -- cgit v1.1 From 8a7a947faaeeaeac2f74f695cefd6eb3e774dc15 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Oct 2009 14:30:25 +0100 Subject: Remove the using() constructs from the new style database modules; they caused the underlying connection of a reader or command to be closed before the reader or command itself. Added the proper logic to Close and dispose items in CloseDBConnection. Readers and Connections need Close(), Commands need Dispose(), in the order Reader, Command, Connection. Also reinstated 80-column-friendly formatting --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 62 +++++++++++----------- OpenSim/Data/MySQL/MySQLFramework.cs | 14 +++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 74 +++++++++++++-------------- 4 files changed, 77 insertions(+), 75 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index a41f9f8..0780936 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,42 +55,40 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID")) + MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) { - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + ret.PrincipalID = principalID; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); - using (IDataReader result = ExecuteReader(cmd)) + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) { - if (result.Read()) - { - ret.PrincipalID = principalID; - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - CloseDBConnection(cmd); - return ret; - } - else - { - CloseDBConnection(cmd); - return null; - } + if (s == "UUID") + continue; + + ret.Data[s] = result[s].ToString(); } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; } } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f37e9bc..ccd1ab0 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,7 +40,9 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger( + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected MySqlConnection m_Connection; @@ -81,7 +83,8 @@ namespace OpenSim.Data.MySQL errorSeen = true; m_Connection.Close(); - MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = + (MySqlConnection)((ICloneable)m_Connection).Clone(); m_Connection.Dispose(); m_Connection = newConnection; m_Connection.Open(); @@ -102,15 +105,18 @@ namespace OpenSim.Data.MySQL protected IDataReader ExecuteReader(MySqlCommand cmd) { - MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = + (MySqlConnection)((ICloneable)m_Connection).Clone(); newConnection.Open(); cmd.Connection = newConnection; return cmd.ExecuteReader(); } - protected void CloseDBConnection(MySqlCommand cmd) + protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) { + reader.Close(); + cmd.Connection.Close(); cmd.Connection.Dispose(); } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3fe27d5..3b561d1 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -173,7 +173,7 @@ namespace OpenSim.Data.MySQL retList.Add(ret); } - CloseDBConnection(cmd); + CloseDBConnection(result, cmd); } return retList; diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 38a6f55..0bbc3f5 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -64,48 +64,46 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) { - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; - using (IDataReader result = ExecuteReader(cmd)) + if (m_ColumnNames == null) { - if (result.Read()) - { - ret.PrincipalID = principalID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - if (s == "ScopeID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - CloseDBConnection(cmd); - return ret; - } - else - { - CloseDBConnection(cmd); - return null; - } + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; } } -- cgit v1.1 From 2a060136bd89174a3071de9458c25af133c01b64 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Oct 2009 15:28:38 +0100 Subject: Lock the heartbeat against multiple invocations. May prevent deadlocks and/or runaway thread use --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d0dc021..c863c3b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -137,6 +137,8 @@ namespace OpenSim.Region.Framework.Scenes protected IAssetService m_AssetService = null; protected IAuthorizationService m_AuthorizationService = null; + private Object m_heartbeatLock = new Object(); + public IAssetService AssetService { get @@ -942,6 +944,9 @@ namespace OpenSim.Region.Framework.Scenes /// private void Heartbeat(object sender) { + if (!Monitor.TryEnter(m_heartbeatLock)) + return; + try { Update(); @@ -952,6 +957,11 @@ namespace OpenSim.Region.Framework.Scenes catch (ThreadAbortException) { } + finally + { + Monitor.Pulse(m_heartbeatLock); + Monitor.Exit(m_heartbeatLock); + } } /// -- cgit v1.1 From d4d060b57d380c9a19536bde79013b7634dbdf83 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 07:49:05 -0700 Subject: Commenting the DEBUG code that I added yesterday, because it's causing mono to fail with https://bugzilla.novell.com/show_bug.cgi?id=538854 --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d0dc021..df9b163 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -962,12 +962,12 @@ namespace OpenSim.Region.Framework.Scenes int maintc = 0; while (!shuttingdown) { -#if DEBUG - int w = 0, io = 0; - ThreadPool.GetAvailableThreads(out w, out io); - if ((w < 10) || (io < 10)) - m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); -#endif +//#if DEBUG +// int w = 0, io = 0; +// ThreadPool.GetAvailableThreads(out w, out io); +// if ((w < 10) || (io < 10)) +// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); +//#endif maintc = Environment.TickCount; TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; -- cgit v1.1 From e474fc2fdbc424e64ce3a0f249b0d0afa44d86eb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 08:50:25 -0700 Subject: Corrected words in error message. --- OpenSim/Framework/Communications/RestClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 7a73506..d98f47d 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -318,11 +318,11 @@ namespace OpenSim.Framework.Communications HttpWebResponse errorResponse = e.Response as HttpWebResponse; if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) { - m_log.Warn("[ASSET] Asset not found (404)"); + m_log.Warn("[REST CLIENT] Resource not found (404)"); } else { - m_log.Error("[ASSET] Error fetching asset from asset server"); + m_log.Error("[REST CLIENT] Error fetching resource from server " + _request.Address.ToString()); m_log.Debug(e.ToString()); } -- cgit v1.1 From 3db4d38645260b0299e082b47b010dddf569bf31 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 09:54:15 -0700 Subject: Removing dependencies on System.Runtime.Remoting. --- OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 44e850b..6c89ac8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs @@ -61,6 +61,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void OnRegionUp(GridRegion otherRegion) { + // This shouldn't happen + if (otherRegion == null) + return; + m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); -- cgit v1.1 From 77b4abaa251929a4d6079d766f041f997071dc46 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 11:08:11 -0700 Subject: * Removed verbose debug message * Restored HG inventory access which had been lost upon adding a 3rd argument to inventory and asset server handlers * Fixed a stupid bug in the InventoryConnector which was making move items do things twice --- .../ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs | 2 +- .../Inventory/InventoryServiceInConnectorModule.cs | 2 +- OpenSim/Server/Base/ServerUtils.cs | 2 +- OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | 1 + OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs | 7 ------- 5 files changed, 4 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index bb9a4b2..879cc70 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset m_log.Info("[RegionAssetService]: Starting..."); - Object[] args = new Object[] { m_Config, MainServer.Instance }; + Object[] args = new Object[] { m_Config, MainServer.Instance, string.Empty }; ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index c326818..54c6d89 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory m_log.Info("[RegionInventoryService]: Starting..."); - Object[] args = new Object[] { m_Config, MainServer.Instance }; + Object[] args = new Object[] { m_Config, MainServer.Instance, String.Empty }; ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:InventoryServiceInConnector", args); } diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 9d9735e..0964caa 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -260,7 +260,7 @@ namespace OpenSim.Server.Base public static Dictionary ParseXmlResponse(string data) { - m_log.DebugFormat("[XXX]: received xml string: {0}", data); + //m_log.DebugFormat("[XXX]: received xml string: {0}", data); Dictionary ret = new Dictionary(); diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index ca45263..3c92209 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs @@ -77,6 +77,7 @@ namespace OpenSim.Server.Handlers.Inventory m_doLookup = serverConfig.GetBoolean("SessionAuthentication", false); AddHttpHandlers(server); + m_log.Debug("[INVENTORY HANDLER]: handlers initialized"); } protected virtual void AddHttpHandlers(IHttpServer m_httpServer) diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5443891..e047f71 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -416,13 +416,6 @@ namespace OpenSim.Services.Connectors e.Source, e.Message); } - foreach (InventoryItemBase item in items) - { - InventoryItemBase itm = this.QueryItem(userID, item, sessionID); - itm.Name = item.Name; - itm.Folder = item.Folder; - this.UpdateItem(userID, itm, sessionID); - } } private void MoveItemsCompleted(IAsyncResult iar) -- cgit v1.1