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,7 +250,8 @@ 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[] { '/' });
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); m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
return; return;
} }
@ -268,35 +269,42 @@ 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];
m_InventoryURLs.Remove(userID); m_InventoryURLs.Remove(userID);
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)
{ {
if (m_InventoryURLs.ContainsKey(userID)) lock (m_InventoryURLs)
return m_InventoryURLs[userID]; {
if (m_InventoryURLs.ContainsKey(userID))
return m_InventoryURLs[userID];
}
CacheInventoryServiceURL(userID); CacheInventoryServiceURL(userID);
if (m_InventoryURLs.ContainsKey(userID)) lock (m_InventoryURLs)
return m_InventoryURLs[userID]; {
if (m_InventoryURLs.ContainsKey(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