From c2581c95779bbf17538e0dedef89ca8b739cef2e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 16 May 2008 17:47:34 +0000 Subject: * Cache knowledge in the region server that the asset service has reported an asset to be missing * This prevents repeated requests for the same missing asset to the asset server, hopefully reducing the load a little --- .../Framework/Communications/Cache/AssetCache.cs | 43 +++++++++++++++------- .../Communications/Cache/AssetServerBase.cs | 2 +- OpenSim/Framework/IAssetServer.cs | 3 +- 3 files changed, 33 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e1d5d32..e6a0852 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache /// private Dictionary Textures; - /// + /// /// Assets requests which are waiting for asset server data. This includes texture requests /// private Dictionary RequestedAssets; @@ -75,7 +75,6 @@ namespace OpenSim.Framework.Communications.Cache /// private List AssetRequests; - /// /// Until the asset request is fulfilled, each asset request is associated with a list of requesters /// @@ -166,11 +165,11 @@ namespace OpenSim.Framework.Communications.Cache m_assetServer = assetServer; m_assetServer.SetReceiver(this); - m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - m_assetCacheThread.Name = "AssetCacheThread"; - m_assetCacheThread.IsBackground = true; - m_assetCacheThread.Start(); - ThreadTracker.Add(m_assetCacheThread); + m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + m_assetCacheThread.Name = "AssetCacheThread"; + m_assetCacheThread.IsBackground = true; + m_assetCacheThread.Start(); + ThreadTracker.Add(m_assetCacheThread); } /// @@ -452,10 +451,19 @@ namespace OpenSim.Framework.Communications.Cache } // See IAssetReceiver - public void AssetNotFound(LLUUID assetID) + public void AssetNotFound(LLUUID assetID, bool IsTexture) { - // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); + if (IsTexture) + { + Textures[assetID] = null; + } + else + { + Assets[assetID] = null; + } + // Notify requesters for this asset AssetRequestsList reqList = null; lock (RequestLists) @@ -509,7 +517,7 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Make an asset request the result of which will be packeted up and sent directly back to the client. + /// Handle an asset request from the client. The result will be sent back asynchronously. /// /// /// @@ -546,12 +554,21 @@ namespace OpenSim.Framework.Communications.Cache RequestedAssets.Add(requestID, request); m_assetServer.RequestAsset(requestID, false); } + return; } - //it is in our cache + + // It has an entry in our cache AssetInfo asset = Assets[requestID]; - - // add to the AssetRequests list + + // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. + if (null == asset) + { + m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing", requestID); + return; + } + + // The asset is knosn to exist and is in our cache, so add it to the AssetRequests list AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; req.RequestAssetID = requestID; diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index b16512c..db71079 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -78,7 +78,7 @@ namespace OpenSim.Framework.Communications.Cache { //m_log.ErrorFormat("[ASSET SERVER]: Asset {0} not found by asset server", req.AssetID); - m_receiver.AssetNotFound(req.AssetID); + m_receiver.AssetNotFound(req.AssetID, req.IsTexture); } } diff --git a/OpenSim/Framework/IAssetServer.cs b/OpenSim/Framework/IAssetServer.cs index 70feb74..0e89348 100644 --- a/OpenSim/Framework/IAssetServer.cs +++ b/OpenSim/Framework/IAssetServer.cs @@ -58,7 +58,8 @@ namespace OpenSim.Framework /// Call back made when an asset server could not retrieve a requested asset /// /// - void AssetNotFound(LLUUID assetID); + /// + void AssetNotFound(LLUUID assetID, bool IsTexture); } public interface IAssetPlugin -- cgit v1.1