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.
0.7.4-post-fixes
Justin Clark-Casey (justincc) 2012-09-25 23:30:25 +01:00
parent 7112e860dc
commit 39fe1ba028
1 changed files with 18 additions and 19 deletions

View File

@ -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.
/// </summary>
/// <param name="item"></param>
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);
}
/// <summary>
/// Store the asset for the given task item when it has been uploaded.
/// </summary>
/// <param name="taskItem"></param>
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);
}
}
}