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.
connector_plugin
Justin Clark-Casey (justincc) 2012-09-25 23:30:25 +01:00
parent b96a53962b
commit ddd9384b39
1 changed files with 18 additions and 19 deletions

View File

@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
public AssetXferUploader( public AssetXferUploader(
AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile) AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile)
{ {
m_asset = new AssetBase();
m_transactions = transactions; m_transactions = transactions;
m_transactionID = transactionID; m_transactionID = transactionID;
m_Scene = scene; m_Scene = scene;
@ -188,9 +190,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
ourClient = remoteClient; ourClient = remoteClient;
m_asset = new AssetBase() { FullID = assetID }; m_asset.FullID = assetID;
m_asset.Name = "blank";
m_asset.Description = "empty";
m_asset.Type = type; m_asset.Type = type;
m_asset.CreatorID = remoteClient.AgentId.ToString(); m_asset.CreatorID = remoteClient.AgentId.ToString();
m_asset.Data = data; m_asset.Data = data;
@ -232,22 +232,15 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
if (m_createItem) if (m_createItem)
{ {
DoCreateItem(m_createItemCallback); CompleteCreateItem(m_createItemCallback);
} }
else if (m_updateItem) else if (m_updateItem)
{ {
StoreAssetForItemUpdate(m_updateItemData); CompleteItemUpdate(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);
} }
else if (m_updateTaskItem) else if (m_updateTaskItem)
{ {
StoreAssetForTaskItemUpdate(m_updateTaskItemData); CompleteTaskItemUpdate(m_updateTaskItemData);
m_transactions.RemoveXferUploader(m_transactionID);
} }
// else if (m_storeLocal) // else if (m_storeLocal)
// { // {
@ -305,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{ {
if (m_uploadState == UploadState.Complete) if (m_uploadState == UploadState.Complete)
{ {
DoCreateItem(callbackID); CompleteCreateItem(callbackID);
} }
else else
{ {
@ -332,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
if (m_uploadState == UploadState.Complete) if (m_uploadState == UploadState.Complete)
{ {
StoreAssetForItemUpdate(item); CompleteItemUpdate(item);
} }
else else
{ {
@ -358,7 +351,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
if (m_uploadState == UploadState.Complete) if (m_uploadState == UploadState.Complete)
{ {
StoreAssetForTaskItemUpdate(taskItem); CompleteTaskItemUpdate(taskItem);
} }
else else
{ {
@ -372,29 +365,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
/// Store the asset for the given item when it has been uploaded. /// Store the asset for the given item when it has been uploaded.
/// </summary> /// </summary>
/// <param name="item"></param> /// <param name="item"></param>
private void StoreAssetForItemUpdate(InventoryItemBase item) private void CompleteItemUpdate(InventoryItemBase item)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}",
// m_asset.FullID, item.Name, ourClient.Name); // m_asset.FullID, item.Name, ourClient.Name);
m_Scene.AssetService.Store(m_asset); m_Scene.AssetService.Store(m_asset);
m_transactions.RemoveXferUploader(m_transactionID);
} }
/// <summary> /// <summary>
/// Store the asset for the given task item when it has been uploaded. /// Store the asset for the given task item when it has been uploaded.
/// </summary> /// </summary>
/// <param name="taskItem"></param> /// <param name="taskItem"></param>
private void StoreAssetForTaskItemUpdate(TaskInventoryItem taskItem) private void CompleteTaskItemUpdate(TaskInventoryItem taskItem)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", // "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}",
// m_asset.FullID, taskItem.Name, ourClient.Name); // m_asset.FullID, taskItem.Name, ourClient.Name);
m_Scene.AssetService.Store(m_asset); 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); m_Scene.AssetService.Store(m_asset);
@ -420,6 +417,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
ourClient.SendInventoryItemCreateUpdate(item, callbackID); ourClient.SendInventoryItemCreateUpdate(item, callbackID);
else else
ourClient.SendAlertMessage("Unable to create inventory item"); ourClient.SendAlertMessage("Unable to create inventory item");
m_transactions.RemoveXferUploader(m_transactionID);
} }
} }
} }