From e6591ab6302f7830139b7d36514299a2432a25a5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Oct 2010 17:02:02 -0700 Subject: [PATCH] Attempt at fixing mantis #5057 -- CPU pinned high with HGAssetBroker. --- .../Asset/HGAssetBroker.cs | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 034e69272e..e31be21a8c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -219,11 +219,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset else asset = m_GridService.Get(id); - if (asset != null) - { - if (m_Cache != null) - m_Cache.Cache(asset); - } + if (m_Cache != null) + m_Cache.Cache(asset); return asset; } @@ -273,18 +270,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset } if (IsHG(id)) - asset = m_HGService.Get(id); + return m_HGService.GetData(id); else - asset = m_GridService.Get(id); + return m_GridService.GetData(id); - if (asset != null) - { - if (m_Cache != null) - m_Cache.Cache(asset); - return asset.Data; - } - - return null; } public bool Get(string id, Object sender, AssetRetrieved handler) @@ -304,7 +293,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset { return m_HGService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) { - if (a != null && m_Cache != null) + if (m_Cache != null) m_Cache.Cache(a); handler(assetID, s, a); }); @@ -313,7 +302,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset { return m_GridService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) { - if (a != null && m_Cache != null) + if (m_Cache != null) m_Cache.Cache(a); handler(assetID, s, a); }); @@ -331,12 +320,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset m_Cache.Cache(asset); if (asset.Temporary || asset.Local) + { + if (m_Cache != null) + m_Cache.Cache(asset); return asset.ID; + } + string id = string.Empty; if (IsHG(asset.ID)) - return m_HGService.Store(asset); + id = m_HGService.Store(asset); else - return m_GridService.Store(asset); + id = m_GridService.Store(asset); + + if (id != String.Empty) + { + // Placing this here, so that this work with old asset servers that don't send any reply back + // SynchronousRestObjectRequester returns somethins that is not an empty string + if (id != null) + asset.ID = id; + + if (m_Cache != null) + m_Cache.Cache(asset); + } + return id; + } public bool UpdateContent(string id, byte[] data) @@ -363,10 +370,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset if (m_Cache != null) m_Cache.Expire(id); + bool result = false; if (IsHG(id)) - return m_HGService.Delete(id); + result = m_HGService.Delete(id); else - return m_GridService.Delete(id); + result = m_GridService.Delete(id); + + if (result && m_Cache != null) + m_Cache.Expire(id); + + return result; } #region IHyperAssetService