diff options
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 120 |
1 files changed, 58 insertions, 62 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 0669ce9..e1d5d32 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -371,85 +371,81 @@ namespace OpenSim.Framework.Communications.Cache | |||
371 | // See IAssetReceiver | 371 | // See IAssetReceiver |
372 | public void AssetReceived(AssetBase asset, bool IsTexture) | 372 | public void AssetReceived(AssetBase asset, bool IsTexture) |
373 | { | 373 | { |
374 | if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server | 374 | //check if it is a texture or not |
375 | //then add to the correct cache list | ||
376 | //then check for waiting requests for this asset/texture (in the Requested lists) | ||
377 | //and move those requests into the Requests list. | ||
378 | if (IsTexture) | ||
375 | { | 379 | { |
376 | //check if it is a texture or not | 380 | TextureImage image = new TextureImage(asset); |
377 | //then add to the correct cache list | 381 | if (!Textures.ContainsKey(image.FullID)) |
378 | //then check for waiting requests for this asset/texture (in the Requested lists) | ||
379 | //and move those requests into the Requests list. | ||
380 | |||
381 | if (IsTexture) | ||
382 | { | 382 | { |
383 | TextureImage image = new TextureImage(asset); | 383 | Textures.Add(image.FullID, image); |
384 | if (!Textures.ContainsKey(image.FullID)) | ||
385 | { | ||
386 | Textures.Add(image.FullID, image); | ||
387 | 384 | ||
388 | if (StatsManager.SimExtraStats != null) | 385 | if (StatsManager.SimExtraStats != null) |
389 | { | 386 | { |
390 | StatsManager.SimExtraStats.AddTexture(image); | 387 | StatsManager.SimExtraStats.AddTexture(image); |
391 | } | ||
392 | } | 388 | } |
393 | } | 389 | } |
394 | else | 390 | } |
391 | else | ||
392 | { | ||
393 | AssetInfo assetInf = new AssetInfo(asset); | ||
394 | if (!Assets.ContainsKey(assetInf.FullID)) | ||
395 | { | 395 | { |
396 | AssetInfo assetInf = new AssetInfo(asset); | 396 | Assets.Add(assetInf.FullID, assetInf); |
397 | if (!Assets.ContainsKey(assetInf.FullID)) | ||
398 | { | ||
399 | Assets.Add(assetInf.FullID, assetInf); | ||
400 | 397 | ||
401 | if (StatsManager.SimExtraStats != null) | 398 | if (StatsManager.SimExtraStats != null) |
402 | { | 399 | { |
403 | StatsManager.SimExtraStats.AddAsset(assetInf); | 400 | StatsManager.SimExtraStats.AddAsset(assetInf); |
404 | } | 401 | } |
405 | 402 | ||
406 | if (RequestedAssets.ContainsKey(assetInf.FullID)) | 403 | if (RequestedAssets.ContainsKey(assetInf.FullID)) |
407 | { | 404 | { |
408 | AssetRequest req = RequestedAssets[assetInf.FullID]; | 405 | AssetRequest req = RequestedAssets[assetInf.FullID]; |
409 | req.AssetInf = assetInf; | 406 | req.AssetInf = assetInf; |
410 | req.NumPackets = CalculateNumPackets(assetInf.Data); | 407 | req.NumPackets = CalculateNumPackets(assetInf.Data); |
411 | 408 | ||
412 | RequestedAssets.Remove(assetInf.FullID); | 409 | RequestedAssets.Remove(assetInf.FullID); |
413 | AssetRequests.Add(req); | 410 | AssetRequests.Add(req); |
414 | } | ||
415 | } | 411 | } |
416 | } | 412 | } |
413 | } | ||
414 | |||
415 | // Notify requesters for this asset | ||
416 | if (RequestLists.ContainsKey(asset.FullID)) | ||
417 | { | ||
418 | AssetRequestsList reqList = null; | ||
419 | lock (RequestLists) | ||
420 | { | ||
421 | //m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #1)"); | ||
422 | reqList = RequestLists[asset.FullID]; | ||
417 | 423 | ||
418 | // Notify requesters for this asset | 424 | } |
419 | if (RequestLists.ContainsKey(asset.FullID)) | 425 | //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #1)"); |
426 | if (reqList != null) | ||
420 | { | 427 | { |
421 | AssetRequestsList reqList = null; | 428 | //making a copy of the list is not ideal |
429 | //but the old method of locking around this whole block of code was causing a multi-thread lock | ||
430 | //between this and the TextureDownloadModule | ||
431 | //while the localAsset thread running this and trying to send a texture to the callback in the | ||
432 | //texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding | ||
433 | // the lock in the texturedownload module) was trying to | ||
434 | //request a new asset and hitting a lock in here on the RequestLists. | ||
435 | |||
436 | List<NewAssetRequest> theseRequests = new List<NewAssetRequest>(reqList.Requests); | ||
437 | reqList.Requests.Clear(); | ||
438 | |||
422 | lock (RequestLists) | 439 | lock (RequestLists) |
423 | { | 440 | { |
424 | //m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #1)"); | 441 | // m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #2)"); |
425 | reqList = RequestLists[asset.FullID]; | 442 | RequestLists.Remove(asset.FullID); |
426 | |||
427 | } | 443 | } |
428 | //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #1)"); | 444 | //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #2)"); |
429 | if (reqList != null) | ||
430 | { | ||
431 | //making a copy of the list is not ideal | ||
432 | //but the old method of locking around this whole block of code was causing a multi-thread lock | ||
433 | //between this and the TextureDownloadModule | ||
434 | //while the localAsset thread running this and trying to send a texture to the callback in the | ||
435 | //texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding | ||
436 | // the lock in the texturedownload module) was trying to | ||
437 | //request a new asset and hitting a lock in here on the RequestLists. | ||
438 | |||
439 | List<NewAssetRequest> theseRequests = new List<NewAssetRequest>(reqList.Requests); | ||
440 | reqList.Requests.Clear(); | ||
441 | |||
442 | lock (RequestLists) | ||
443 | { | ||
444 | // m_log.Info("AssetCache: Lock taken on requestLists (AssetReceived #2)"); | ||
445 | RequestLists.Remove(asset.FullID); | ||
446 | } | ||
447 | //m_log.Info("AssetCache: Lock released on requestLists (AssetReceived #2)"); | ||
448 | 445 | ||
449 | foreach (NewAssetRequest req in theseRequests) | 446 | foreach (NewAssetRequest req in theseRequests) |
450 | { | 447 | { |
451 | req.Callback(asset.FullID, asset); | 448 | req.Callback(asset.FullID, asset); |
452 | } | ||
453 | } | 449 | } |
454 | } | 450 | } |
455 | } | 451 | } |