add a few locks

0.9.0-post-fixes
UbitUmarov 2017-08-03 17:59:30 +01:00
parent 1830387840
commit f658b68181
1 changed files with 16 additions and 8 deletions

View File

@ -250,6 +250,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (inventoryURL != null && inventoryURL != string.Empty) if (inventoryURL != null && inventoryURL != string.Empty)
{ {
inventoryURL = inventoryURL.Trim(new char[] { '/' }); inventoryURL = inventoryURL.Trim(new char[] { '/' });
lock (m_InventoryURLs)
m_InventoryURLs[userID] = inventoryURL; m_InventoryURLs[userID] = inventoryURL;
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
return; return;
@ -268,18 +269,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (!string.IsNullOrEmpty(inventoryURL)) if (!string.IsNullOrEmpty(inventoryURL))
{ {
inventoryURL = inventoryURL.Trim(new char[] { '/' }); 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); m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
} }
} }
} }
} }
private void DropInventoryServiceURL(UUID userID) private void DropInventoryServiceURL(UUID userID)
{ {
lock (m_InventoryURLs) lock (m_InventoryURLs)
{
if (m_InventoryURLs.ContainsKey(userID)) if (m_InventoryURLs.ContainsKey(userID))
{ {
string url = m_InventoryURLs[userID]; string url = m_InventoryURLs[userID];
@ -287,16 +288,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Removed {0} from the cache of inventory URLs", url); m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Removed {0} from the cache of inventory URLs", url);
} }
} }
}
public string GetInventoryServiceURL(UUID userID) public string GetInventoryServiceURL(UUID userID)
{
lock (m_InventoryURLs)
{ {
if (m_InventoryURLs.ContainsKey(userID)) if (m_InventoryURLs.ContainsKey(userID))
return m_InventoryURLs[userID]; return m_InventoryURLs[userID];
}
CacheInventoryServiceURL(userID); CacheInventoryServiceURL(userID);
lock (m_InventoryURLs)
{
if (m_InventoryURLs.ContainsKey(userID)) if (m_InventoryURLs.ContainsKey(userID))
return m_InventoryURLs[userID]; return m_InventoryURLs[userID];
}
return null; //it means that the methods should forward to local grid's inventory return null; //it means that the methods should forward to local grid's inventory