diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e96a123348..0780936d9c 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,39 +55,41 @@ 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; - using (IDataReader result = ExecuteReader(cmd)) + if (m_ColumnNames == null) { - if (result.Read()) - { - ret.PrincipalID = principalID; + m_ColumnNames = new List(); - 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(); - } - - return ret; - } + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } - } - return null; + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; + } } public bool Store(AuthenticationData data) diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index c756c9cf45..ccd1ab0ed9 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,14 +40,15 @@ 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; protected MySqlFramework(string connectionString) { m_Connection = new MySqlConnection(connectionString); - m_Connection.Open(); } @@ -82,8 +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(); @@ -104,14 +105,19 @@ 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(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 04b24b6362..3b561d14ed 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -172,6 +172,8 @@ namespace OpenSim.Data.MySQL retList.Add(ret); } + + CloseDBConnection(result, cmd); } return retList; diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index c713a119d3..0bbc3f5645 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -64,45 +64,47 @@ 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; + m_ColumnNames = new List(); - 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(); - } - - return ret; - } + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } - } - return null; + 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; + } } public bool Store(UserAccountData data) diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 7a735060fe..d98f47d80b 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()); } diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 632b551f47..56155ddd59 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -238,7 +238,7 @@ namespace OpenSim.Framework.Servers List threads = ThreadTracker.GetThreads(); if (threads == null) { - sb.Append("Thread tracking is only enabled in DEBUG mode."); + sb.Append("OpenSim thread tracking is only enabled in DEBUG mode."); } else { @@ -264,6 +264,12 @@ namespace OpenSim.Framework.Servers } } } + int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; + ThreadPool.GetAvailableThreads(out workers, out ports); + ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts); + + sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine); + sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine); return sb.ToString(); } diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs index 8a490f7233..4543fd5e99 100644 --- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs @@ -28,14 +28,21 @@ using System; using System.IO; using System.Net; +using System.Reflection; using System.Text; using System.Xml; using System.Xml.Serialization; +using log4net; + namespace OpenSim.Framework.Servers.HttpServer { public class SynchronousRestFormsRequester { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + /// /// Perform a synchronous REST request. /// @@ -72,8 +79,9 @@ namespace OpenSim.Framework.Servers.HttpServer requestStream = request.GetRequestStream(); requestStream.Write(buffer.ToArray(), 0, length); } - catch + catch (Exception e) { + m_log.DebugFormat("[FORMS]: exception occured on sending request {0}", e.Message); } finally { @@ -102,7 +110,10 @@ namespace OpenSim.Framework.Servers.HttpServer respstring = reader.ReadToEnd(); } } - catch { } + catch (Exception e) + { + m_log.DebugFormat("[FORMS]: exception occured on receiving reply {0}", e.Message); + } finally { if (respStream != null) @@ -114,6 +125,7 @@ namespace OpenSim.Framework.Servers.HttpServer catch (System.InvalidOperationException) { // This is what happens when there is invalid XML + m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request"); } return respstring; } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 2120d33d42..cc290edd99 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP J2KImage imgrequest; // Do a linear search for this texture download - lock (m_priorityQueue) + lock (m_syncRoot) m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); if (imgrequest != null) @@ -99,7 +99,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP try { - lock (m_priorityQueue) + lock (m_syncRoot) m_priorityQueue.Delete(imgrequest.PriorityQueueHandle); } catch (Exception) { } @@ -211,7 +211,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { J2KImage image = null; - lock (m_priorityQueue) + lock (m_syncRoot) { if (m_priorityQueue.Count > 0) @@ -230,23 +230,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP { image.PriorityQueueHandle = null; - lock (m_priorityQueue) - m_priorityQueue.Add(ref image.PriorityQueueHandle, image); + lock (m_syncRoot) + try + { + m_priorityQueue.Add(ref image.PriorityQueueHandle, image); + } + catch (Exception) { } } void RemoveImageFromQueue(J2KImage image) { - try - { - lock (m_priorityQueue) + lock (m_syncRoot) + try + { m_priorityQueue.Delete(image.PriorityQueueHandle); - } - catch (Exception) { } + } + catch (Exception) { } } void UpdateImageInQueue(J2KImage image) { - lock (m_priorityQueue) + lock (m_syncRoot) { try { m_priorityQueue.Replace(image.PriorityQueueHandle, image); } catch (Exception) diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 5a5ad7e493..66ca7c2336 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs @@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Asset { if (maximalSize <= 0 || maximalCount <= 0) { - Log.Info("[ASSET CACHE]: Cenome asset cache is not enabled."); + //Log.Debug("[ASSET CACHE]: Cenome asset cache is not enabled."); m_enabled = false; return; } @@ -194,7 +194,7 @@ namespace OpenSim.Region.CoreModules.Asset CnmSynchronizedCache.Synchronized(new CnmMemoryCache( maximalSize, maximalCount, expirationTime)); m_enabled = true; - Log.InfoFormat( + Log.DebugFormat( "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})", maximalSize, maximalCount, @@ -263,7 +263,7 @@ namespace OpenSim.Region.CoreModules.Asset if (m_getCount == m_debugEpoch) { - Log.InfoFormat( + Log.DebugFormat( "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes", m_cachedCount, m_getCount, @@ -333,7 +333,7 @@ namespace OpenSim.Region.CoreModules.Asset return; string name = moduleConfig.GetString("AssetCaching"); - Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); + //Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); if (name != Name) return; @@ -343,14 +343,14 @@ namespace OpenSim.Region.CoreModules.Asset int maxCount = DefaultMaxCount; TimeSpan expirationTime = DefaultExpirationTime; - IConfig assetConfig = source.Configs[ "AssetCache" ]; + IConfig assetConfig = source.Configs["AssetCache"]; if (assetConfig != null) { // Get optional configurations maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize); maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount); expirationTime = - TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int) DefaultExpirationTime.TotalMinutes)); + TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int)DefaultExpirationTime.TotalMinutes)); // Debugging purposes only m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0); diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 2de40d28ee..0a7e736599 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.Asset if (moduleConfig != null) { string name = moduleConfig.GetString("AssetCaching"); - m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); + //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); if (name == Name) { diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c0bb70cafc..b81ab41351 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -636,11 +636,8 @@ namespace Flotsam.RegionModules.AssetCache m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk"); } - - } #endregion - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 8d8e0fe481..4869f5d6b8 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Asset if (moduleConfig != null) { string name = moduleConfig.GetString("AssetCaching"); - m_log.DebugFormat("[ASSET CACHE] name = {0} (this module's name: {1}). Sync? ", name, Name, m_Cache.IsSynchronized); + //m_log.DebugFormat("[ASSET CACHE] name = {0} (this module's name: {1}). Sync? ", name, Name, m_Cache.IsSynchronized); if (name == Name) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3ca4882327..1c72488bbc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -206,6 +206,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { + GridRegion region = null; + + // First see if it's a neighbour, even if it isn't on this sim. + // Neighbour data is cached in memory, so this is fast + foreach (RegionCache rcache in m_LocalCache.Values) + { + region = rcache.GetRegionByPosition(x, y); + if (region != null) + { + return region; + } + } + + // Then try on this sim (may be a lookup in DB if this is using MySql). return m_GridService.GetRegionByPosition(scopeID, x, y); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 2b336bb0a2..44e850bae3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs @@ -29,10 +29,12 @@ using System; using System.Collections.Generic; using System.Reflection; +using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenMetaverse; using log4net; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid @@ -75,5 +77,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { return new List(m_neighbours.Values); } + + public GridRegion GetRegionByPosition(int x, int y) + { + uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; + uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; + ulong handle = Utils.UIntsToLong(xsnap, ysnap); + + if (m_neighbours.ContainsKey(handle)) + return m_neighbours[handle]; + + return null; + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c06a58f397..9418e3d8f6 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); + } } /// @@ -962,6 +972,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 maintc = Environment.TickCount; TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 06bae5a37f..c02b1234ec 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -3488,7 +3488,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override void UnCombine(PhysicsScene pScene) { IntPtr localGround = IntPtr.Zero; - float[] localHeightfield; + //float[] localHeightfield; bool proceed = false; List geomDestroyList = new List(); @@ -3785,16 +3785,13 @@ namespace OpenSim.Region.Physics.OdePlugin sides.Z = 0.5f; ds.DrawBox(ref pos, ref R, ref sides); - - } } } } public void start(int unused) - { - + { ds.SetViewpoint(ref xyz, ref hpr); } #endif diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 0964caaed7..9d9735e439 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/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index e22328dc66..433ed0b700 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -67,43 +67,50 @@ namespace OpenSim.Server.Handlers.Grid //m_log.DebugFormat("[XXX]: query String: {0}", body); - Dictionary request = - ServerUtils.ParseQueryString(body); - - if (!request.ContainsKey("METHOD")) - return FailureResult(); - - string method = request["METHOD"]; - - switch (method) + try { - case "register": - return Register(request); + Dictionary request = + ServerUtils.ParseQueryString(body); - case "deregister": - return Deregister(request); + if (!request.ContainsKey("METHOD")) + return FailureResult(); - case "get_neighbours": - return GetNeighbours(request); + string method = request["METHOD"]; - case "get_region_by_uuid": - return GetRegionByUUID(request); + switch (method) + { + case "register": + return Register(request); - case "get_region_by_position": - return GetRegionByPosition(request); + case "deregister": + return Deregister(request); - case "get_region_by_name": - return GetRegionByName(request); + case "get_neighbours": + return GetNeighbours(request); - case "get_regions_by_name": - return GetRegionsByName(request); + case "get_region_by_uuid": + return GetRegionByUUID(request); - case "get_region_range": - return GetRegionRange(request); + case "get_region_by_position": + return GetRegionByPosition(request); + case "get_region_by_name": + return GetRegionByName(request); + + case "get_regions_by_name": + return GetRegionsByName(request); + + case "get_region_range": + return GetRegionRange(request); + + } + m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID HANDLER]: Exception {0}", e); } - m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); return FailureResult(); } @@ -113,7 +120,7 @@ namespace OpenSim.Server.Handlers.Grid byte[] Register(Dictionary request) { UUID scopeID = UUID.Zero; - if (request["SCOPEID"] != null) + if (request.ContainsKey("SCOPEID")) UUID.TryParse(request["SCOPEID"], out scopeID); else m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); @@ -137,11 +144,21 @@ namespace OpenSim.Server.Handlers.Grid } Dictionary rinfoData = new Dictionary(); - foreach (KeyValuePair kvp in request) - rinfoData[kvp.Key] = kvp.Value; - GridRegion rinfo = new GridRegion(rinfoData); + GridRegion rinfo = null; + try + { + foreach (KeyValuePair kvp in request) + rinfoData[kvp.Key] = kvp.Value; + rinfo = new GridRegion(rinfoData); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e); + } - bool result = m_GridService.RegisterRegion(scopeID, rinfo); + bool result = false; + if (rinfo != null) + result = m_GridService.RegisterRegion(scopeID, rinfo); if (result) return SuccessResult(); diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ba46b0d71f..acdf5587de 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs @@ -109,8 +109,13 @@ namespace OpenSim.Services.Connectors { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) + if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success")) return true; + else if (!replyData.ContainsKey("Result")) + m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); + else + m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); + } else m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 991acf23ee..a2e4771d4b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -69,18 +69,40 @@ namespace OpenSim.Services.GridService ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { // Region reregistering in other coordinates. Delete the old entry - m_Database.Delete(regionInfos.RegionID); + m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + + try + { + m_Database.Delete(regionInfos.RegionID); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); + } } // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; - m_Database.Store(rdata); + try + { + m_Database.Store(rdata); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); + } + + m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + return true; } public bool DeregisterRegion(UUID regionID) { + m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID); return m_Database.Delete(regionID); } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index fa8dc9db26..5cb51b28d9 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -312,7 +312,7 @@ ; Uncomment below to enable llRemoteData/remote channels ; remoteDataPort = 20800 - grid_server_url = "http://127.0.0.1:8001" + grid_server_url = "http://127.0.0.1:8003" grid_send_key = "null" grid_recv_key = "null" @@ -322,7 +322,7 @@ asset_server_url = "http://127.0.0.1:8003" - inventory_server_url = "http://127.0.0.1:8004" + inventory_server_url = "http://127.0.0.1:8003" ; The MessagingServer is a companion of the UserServer. It uses ; user_send_key and user_recv_key, too diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 6607a1a369..3bc9b6ccdb 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -13,13 +13,13 @@ ; ; change this to your grid-wide inventory server ; - InventoryServerURI = "http://myinventoryserver.com:8004" + InventoryServerURI = "http://myinventoryserver.com:8003" [GridService] ; ; change this to your grid-wide grid server ; - GridServerURI = "http://mygridserver.com:8001" + GridServerURI = "http://mygridserver.com:8003" [Modules] ;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.