mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
mantis 8890: waste CPU checking if asset id == Zero on get; several changes on region Asset connector
This commit is contained in:
@@ -403,7 +403,6 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
public void Cache(AssetBase asset, bool replace = false)
|
||||
{
|
||||
// TODO: Spawn this off to some seperate thread to do the actual writing
|
||||
if (asset != null)
|
||||
{
|
||||
//m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Caching asset with id {0}", asset.ID);
|
||||
@@ -423,9 +422,7 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
public void CacheNegative(string id)
|
||||
{
|
||||
if (m_negativeCacheEnabled)
|
||||
{
|
||||
m_negativeCache.Add(id, m_negativeExpiration);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -578,6 +575,9 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
m_Requests++;
|
||||
|
||||
if (id.Equals(Util.UUIDZeroString))
|
||||
return false;
|
||||
|
||||
if (m_negativeCache.ContainsKey(id))
|
||||
return false;
|
||||
|
||||
@@ -696,6 +696,9 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
if (m_MemoryCacheEnabled)
|
||||
m_MemoryCache.Remove(id);
|
||||
|
||||
if (m_negativeCacheEnabled)
|
||||
m_negativeCache.Remove(id);
|
||||
|
||||
if (m_FileCacheEnabled)
|
||||
{
|
||||
string filename = GetFileName(id);
|
||||
|
||||
@@ -248,11 +248,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
}
|
||||
}
|
||||
|
||||
if (id.Equals(Util.UUIDZeroString))
|
||||
return false;
|
||||
|
||||
return m_AssetService.Get(id, sender, delegate (string assetID, object s, AssetBase a)
|
||||
{
|
||||
if ((a != null) && (m_Cache != null))
|
||||
m_Cache.Cache(a);
|
||||
|
||||
if(m_Cache != null)
|
||||
{
|
||||
if (a == null)
|
||||
m_Cache.CacheNegative(assetID);
|
||||
else
|
||||
m_Cache.Cache(a);
|
||||
}
|
||||
// if (null == a)
|
||||
// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id);
|
||||
|
||||
@@ -272,18 +279,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
|
||||
if (asset.Local)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[LOCAL ASSET SERVICE CONNECTOR]: Returning asset {0} {1} without querying database since status Temporary = {2}, Local = {3}",
|
||||
// asset.Name, asset.ID, asset.Temporary, asset.Local);
|
||||
|
||||
return asset.ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[LOCAL ASSET SERVICE CONNECTOR]: Passing {0} {1} on to asset service for storage, status Temporary = {2}, Local = {3}",
|
||||
// asset.Name, asset.ID, asset.Temporary, asset.Local);
|
||||
|
||||
return m_AssetService.Store(asset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,8 +305,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
return null;
|
||||
}
|
||||
if(StoreOnLocalGrid)
|
||||
Store(asset);
|
||||
else if (m_Cache != null)
|
||||
StoreLocal(asset);
|
||||
if (m_Cache != null)
|
||||
m_Cache.Cache(asset);
|
||||
}
|
||||
else if (m_Cache != null)
|
||||
@@ -345,6 +345,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
|
||||
if (asset == null)
|
||||
{
|
||||
if (id.Equals(Util.UUIDZeroString))
|
||||
return false;
|
||||
|
||||
lock (m_AssetHandlers)
|
||||
{
|
||||
AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate (AssetBase _asset) { callBack(id, sender, _asset); });
|
||||
|
||||
Reference in New Issue
Block a user