From f658b68181c6161520cfdf9537005c7415ea545a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 3 Aug 2017 17:59:30 +0100 Subject: [PATCH] add a few locks --- .../Inventory/HGInventoryBroker.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 5efdd9b7cf..7a4f981da6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -250,7 +250,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (inventoryURL != null && inventoryURL != string.Empty) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); - m_InventoryURLs[userID] = inventoryURL; + lock (m_InventoryURLs) + m_InventoryURLs[userID] = inventoryURL; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); return; } @@ -268,35 +269,42 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!string.IsNullOrEmpty(inventoryURL)) { inventoryURL = inventoryURL.Trim(new char[] { '/' }); - m_InventoryURLs.Add(userID, inventoryURL); + lock (m_InventoryURLs) + m_InventoryURLs[userID] = inventoryURL; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); } - } - } } private void DropInventoryServiceURL(UUID userID) { lock (m_InventoryURLs) + { if (m_InventoryURLs.ContainsKey(userID)) { string url = m_InventoryURLs[userID]; m_InventoryURLs.Remove(userID); m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Removed {0} from the cache of inventory URLs", url); } + } } public string GetInventoryServiceURL(UUID userID) { - if (m_InventoryURLs.ContainsKey(userID)) - return m_InventoryURLs[userID]; + lock (m_InventoryURLs) + { + if (m_InventoryURLs.ContainsKey(userID)) + return m_InventoryURLs[userID]; + } CacheInventoryServiceURL(userID); - if (m_InventoryURLs.ContainsKey(userID)) - return m_InventoryURLs[userID]; + lock (m_InventoryURLs) + { + if (m_InventoryURLs.ContainsKey(userID)) + return m_InventoryURLs[userID]; + } return null; //it means that the methods should forward to local grid's inventory