Shuffle order of code in invnetory connector GetFolderContent() calls to avoid a possible race condition

remove-scene-viewer
Justin Clark-Casey (justincc) 2011-09-15 18:36:22 +01:00
parent 42f1b88eb2
commit 8fb3e71b14
3 changed files with 19 additions and 13 deletions

View File

@ -185,15 +185,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public InventoryCollection GetFolderContent(UUID userID, UUID folderID) public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{ {
InventoryCollection invCol = m_InventoryService.GetFolderContent(userID, folderID); InventoryCollection invCol = m_InventoryService.GetFolderContent(userID, folderID);
Util.FireAndForget(delegate
if (UserManager != null)
{ {
if (UserManager != null) // Protect ourselves against the caller subsequently modifying the items list
List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
Util.FireAndForget(delegate
{ {
// Protect ourselves against the caller subsequently modifying the items list foreach (InventoryItemBase item in items)
foreach (InventoryItemBase item in new List<InventoryItemBase>(invCol.Items))
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
} });
}); }
return invCol; return invCol;
} }

View File

@ -193,15 +193,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
public InventoryCollection GetFolderContent(UUID userID, UUID folderID) public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{ {
InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
Util.FireAndForget(delegate
if (UserManager != null)
{ {
if (UserManager != null) // Protect ourselves against the caller subsequently modifying the items list
List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
Util.FireAndForget(delegate
{ {
// Protect ourselves against the caller subsequently modifying the items list foreach (InventoryItemBase item in items)
foreach (InventoryItemBase item in new List<InventoryItemBase>(invCol.Items))
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
} });
}); }
return invCol; return invCol;
} }

View File

@ -875,7 +875,7 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat( // m_log.DebugFormat(
// "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items",
// m_part.Name, m_part.LocalId, m_part.UUID, client.Name); // m_part.Name, m_part.LocalId, m_part.UUID, client.Name);
client.SendTaskInventory(m_part.UUID, 0, new byte[0]); client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return; return;
} }