From 39fe1ba028074a881969234f60c27ffaee44bcb0 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Sep 2012 23:30:25 +0100 Subject: [PATCH] Fix very recently introduced race condition where a CreateNewItem outracing an UploadAsset request could throw an exception because m_asset did not yet exist. This was accidentally introduced in 4fc0cfb This commit also consistently removes the AssetXferUploader when the transaction completes, no matter if it completed on asset upload or item operation. The amount of data being retained was small, since this was clothing/bodypart metadata in the asset rather than textures themselves. --- .../AssetTransaction/AssetXferUploader.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 8d21202541..8add4bb073 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction public AssetXferUploader( AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile) { + m_asset = new AssetBase(); + m_transactions = transactions; m_transactionID = transactionID; m_Scene = scene; @@ -188,9 +190,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction ourClient = remoteClient; - m_asset = new AssetBase() { FullID = assetID }; - m_asset.Name = "blank"; - m_asset.Description = "empty"; + m_asset.FullID = assetID; m_asset.Type = type; m_asset.CreatorID = remoteClient.AgentId.ToString(); m_asset.Data = data; @@ -232,22 +232,15 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (m_createItem) { - DoCreateItem(m_createItemCallback); + CompleteCreateItem(m_createItemCallback); } else if (m_updateItem) { - StoreAssetForItemUpdate(m_updateItemData); - - // Remove ourselves from the list of transactions if completion was delayed until the transaction - // was complete. - // TODO: Should probably do the same for create item. - m_transactions.RemoveXferUploader(m_transactionID); + CompleteItemUpdate(m_updateItemData); } else if (m_updateTaskItem) { - StoreAssetForTaskItemUpdate(m_updateTaskItemData); - - m_transactions.RemoveXferUploader(m_transactionID); + CompleteTaskItemUpdate(m_updateTaskItemData); } // else if (m_storeLocal) // { @@ -305,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (m_uploadState == UploadState.Complete) { - DoCreateItem(callbackID); + CompleteCreateItem(callbackID); } else { @@ -332,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (m_uploadState == UploadState.Complete) { - StoreAssetForItemUpdate(item); + CompleteItemUpdate(item); } else { @@ -358,7 +351,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (m_uploadState == UploadState.Complete) { - StoreAssetForTaskItemUpdate(taskItem); + CompleteTaskItemUpdate(taskItem); } else { @@ -372,29 +365,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// Store the asset for the given item when it has been uploaded. /// /// - private void StoreAssetForItemUpdate(InventoryItemBase item) + private void CompleteItemUpdate(InventoryItemBase item) { // m_log.DebugFormat( // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", // m_asset.FullID, item.Name, ourClient.Name); m_Scene.AssetService.Store(m_asset); + + m_transactions.RemoveXferUploader(m_transactionID); } /// /// Store the asset for the given task item when it has been uploaded. /// /// - private void StoreAssetForTaskItemUpdate(TaskInventoryItem taskItem) + private void CompleteTaskItemUpdate(TaskInventoryItem taskItem) { // m_log.DebugFormat( // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", // m_asset.FullID, taskItem.Name, ourClient.Name); m_Scene.AssetService.Store(m_asset); + + m_transactions.RemoveXferUploader(m_transactionID); } - private void DoCreateItem(uint callbackID) + private void CompleteCreateItem(uint callbackID) { m_Scene.AssetService.Store(m_asset); @@ -420,6 +417,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction ourClient.SendInventoryItemCreateUpdate(item, callbackID); else ourClient.SendAlertMessage("Unable to create inventory item"); + + m_transactions.RemoveXferUploader(m_transactionID); } } } \ No newline at end of file