aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-09-25 23:30:25 +0100
committerJustin Clark-Casey (justincc)2012-09-25 23:30:25 +0100
commitddd9384b3901f532243c1e8018334385b84290d1 (patch)
tree3030f101ac3999ffb2008c76f456966ec2021f8d /OpenSim
parentComment out old m_storeLocal from AssetXferUploader. (diff)
downloadopensim-SC-ddd9384b3901f532243c1e8018334385b84290d1.zip
opensim-SC-ddd9384b3901f532243c1e8018334385b84290d1.tar.gz
opensim-SC-ddd9384b3901f532243c1e8018334385b84290d1.tar.bz2
opensim-SC-ddd9384b3901f532243c1e8018334385b84290d1.tar.xz
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.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs37
1 files changed, 18 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index 8d21202..8add4bb 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
104 public AssetXferUploader( 104 public AssetXferUploader(
105 AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile) 105 AgentAssetTransactions transactions, Scene scene, UUID transactionID, bool dumpAssetToFile)
106 { 106 {
107 m_asset = new AssetBase();
108
107 m_transactions = transactions; 109 m_transactions = transactions;
108 m_transactionID = transactionID; 110 m_transactionID = transactionID;
109 m_Scene = scene; 111 m_Scene = scene;
@@ -188,9 +190,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
188 190
189 ourClient = remoteClient; 191 ourClient = remoteClient;
190 192
191 m_asset = new AssetBase() { FullID = assetID }; 193 m_asset.FullID = assetID;
192 m_asset.Name = "blank";
193 m_asset.Description = "empty";
194 m_asset.Type = type; 194 m_asset.Type = type;
195 m_asset.CreatorID = remoteClient.AgentId.ToString(); 195 m_asset.CreatorID = remoteClient.AgentId.ToString();
196 m_asset.Data = data; 196 m_asset.Data = data;
@@ -232,22 +232,15 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
232 232
233 if (m_createItem) 233 if (m_createItem)
234 { 234 {
235 DoCreateItem(m_createItemCallback); 235 CompleteCreateItem(m_createItemCallback);
236 } 236 }
237 else if (m_updateItem) 237 else if (m_updateItem)
238 { 238 {
239 StoreAssetForItemUpdate(m_updateItemData); 239 CompleteItemUpdate(m_updateItemData);
240
241 // Remove ourselves from the list of transactions if completion was delayed until the transaction
242 // was complete.
243 // TODO: Should probably do the same for create item.
244 m_transactions.RemoveXferUploader(m_transactionID);
245 } 240 }
246 else if (m_updateTaskItem) 241 else if (m_updateTaskItem)
247 { 242 {
248 StoreAssetForTaskItemUpdate(m_updateTaskItemData); 243 CompleteTaskItemUpdate(m_updateTaskItemData);
249
250 m_transactions.RemoveXferUploader(m_transactionID);
251 } 244 }
252// else if (m_storeLocal) 245// else if (m_storeLocal)
253// { 246// {
@@ -305,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
305 { 298 {
306 if (m_uploadState == UploadState.Complete) 299 if (m_uploadState == UploadState.Complete)
307 { 300 {
308 DoCreateItem(callbackID); 301 CompleteCreateItem(callbackID);
309 } 302 }
310 else 303 else
311 { 304 {
@@ -332,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
332 325
333 if (m_uploadState == UploadState.Complete) 326 if (m_uploadState == UploadState.Complete)
334 { 327 {
335 StoreAssetForItemUpdate(item); 328 CompleteItemUpdate(item);
336 } 329 }
337 else 330 else
338 { 331 {
@@ -358,7 +351,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
358 351
359 if (m_uploadState == UploadState.Complete) 352 if (m_uploadState == UploadState.Complete)
360 { 353 {
361 StoreAssetForTaskItemUpdate(taskItem); 354 CompleteTaskItemUpdate(taskItem);
362 } 355 }
363 else 356 else
364 { 357 {
@@ -372,29 +365,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
372 /// Store the asset for the given item when it has been uploaded. 365 /// Store the asset for the given item when it has been uploaded.
373 /// </summary> 366 /// </summary>
374 /// <param name="item"></param> 367 /// <param name="item"></param>
375 private void StoreAssetForItemUpdate(InventoryItemBase item) 368 private void CompleteItemUpdate(InventoryItemBase item)
376 { 369 {
377// m_log.DebugFormat( 370// m_log.DebugFormat(
378// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}", 371// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier item update for {1} for {2}",
379// m_asset.FullID, item.Name, ourClient.Name); 372// m_asset.FullID, item.Name, ourClient.Name);
380 373
381 m_Scene.AssetService.Store(m_asset); 374 m_Scene.AssetService.Store(m_asset);
375
376 m_transactions.RemoveXferUploader(m_transactionID);
382 } 377 }
383 378
384 /// <summary> 379 /// <summary>
385 /// Store the asset for the given task item when it has been uploaded. 380 /// Store the asset for the given task item when it has been uploaded.
386 /// </summary> 381 /// </summary>
387 /// <param name="taskItem"></param> 382 /// <param name="taskItem"></param>
388 private void StoreAssetForTaskItemUpdate(TaskInventoryItem taskItem) 383 private void CompleteTaskItemUpdate(TaskInventoryItem taskItem)
389 { 384 {
390// m_log.DebugFormat( 385// m_log.DebugFormat(
391// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}", 386// "[ASSET XFER UPLOADER]: Storing asset {0} for earlier task item update for {1} for {2}",
392// m_asset.FullID, taskItem.Name, ourClient.Name); 387// m_asset.FullID, taskItem.Name, ourClient.Name);
393 388
394 m_Scene.AssetService.Store(m_asset); 389 m_Scene.AssetService.Store(m_asset);
390
391 m_transactions.RemoveXferUploader(m_transactionID);
395 } 392 }
396 393
397 private void DoCreateItem(uint callbackID) 394 private void CompleteCreateItem(uint callbackID)
398 { 395 {
399 m_Scene.AssetService.Store(m_asset); 396 m_Scene.AssetService.Store(m_asset);
400 397
@@ -420,6 +417,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
420 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 417 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
421 else 418 else
422 ourClient.SendAlertMessage("Unable to create inventory item"); 419 ourClient.SendAlertMessage("Unable to create inventory item");
420
421 m_transactions.RemoveXferUploader(m_transactionID);
423 } 422 }
424 } 423 }
425} \ No newline at end of file 424} \ No newline at end of file