add a Check method to flotsamAssetCache, so to check if a asset is in
cache without actually loading it. Make use limited use of it in avatarfactory textures check. Also on llclientview HandleAgentTextureCached that now should work. Other asset cache modules for now will return false, so are broken. baked textures logic still unchanged. *UNTESTED*avinationmerge
parent
71fc9f29f9
commit
20773dcfcc
|
@ -33,6 +33,7 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
void Cache(AssetBase asset);
|
void Cache(AssetBase asset);
|
||||||
AssetBase Get(string id);
|
AssetBase Get(string id);
|
||||||
|
bool Check(string id);
|
||||||
void Expire(string id);
|
void Expire(string id);
|
||||||
void Clear();
|
void Clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3993,7 +3993,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
const float TIME_DILATION = 1.0f;
|
const float TIME_DILATION = 1.0f;
|
||||||
ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
|
ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
|
||||||
if (terseAgentUpdateBlocks.IsValueCreated)
|
if (terseAgentUpdateBlocks.IsValueCreated)
|
||||||
{
|
{
|
||||||
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
|
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
|
||||||
|
@ -11695,14 +11694,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
cachedresp.WearableData =
|
cachedresp.WearableData =
|
||||||
new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
|
new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
|
||||||
|
|
||||||
for (int i = 0; i < cachedtex.WearableData.Length; i++)
|
IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
|
||||||
|
if (cache == null)
|
||||||
{
|
{
|
||||||
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
|
for (int i = 0; i < cachedtex.WearableData.Length; i++)
|
||||||
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
|
{
|
||||||
cachedresp.WearableData[i].TextureID = UUID.Zero;
|
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
|
||||||
cachedresp.WearableData[i].HostName = new byte[0];
|
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
|
||||||
|
cachedresp.WearableData[i].TextureID = UUID.Zero;
|
||||||
|
cachedresp.WearableData[i].HostName = new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < cachedtex.WearableData.Length; i++)
|
||||||
|
{
|
||||||
|
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
|
||||||
|
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
|
||||||
|
if(cache.Check(cachedtex.WearableData[i].ID.ToString()))
|
||||||
|
cachedresp.WearableData[i].TextureID = UUID.Zero;
|
||||||
|
else
|
||||||
|
cachedresp.WearableData[i].TextureID = UUID.Zero;
|
||||||
|
cachedresp.WearableData[i].HostName = new byte[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedresp.Header.Zerocoded = true;
|
cachedresp.Header.Zerocoded = true;
|
||||||
OutPacket(cachedresp, ThrottleOutPacketType.Task);
|
OutPacket(cachedresp, ThrottleOutPacketType.Task);
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
|
|
||||||
#region IImprovedAssetCache Members
|
#region IImprovedAssetCache Members
|
||||||
|
|
||||||
|
|
||||||
|
public bool Check(string id)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cache asset.
|
/// Cache asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -112,6 +112,10 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// IImprovedAssetCache
|
// IImprovedAssetCache
|
||||||
//
|
//
|
||||||
|
public bool Check(string id)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Cache(AssetBase asset)
|
public void Cache(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -348,6 +348,17 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckFromMemoryCache(string id)
|
||||||
|
{
|
||||||
|
AssetBase asset = null;
|
||||||
|
|
||||||
|
if (m_MemoryCache.TryGetValue(id, out asset))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to get an asset from the file cache.
|
/// Try to get an asset from the file cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -420,6 +431,50 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckFromFileCache(string id)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
string filename = GetFileName(id);
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
// actually check if we can open it, and so update expire
|
||||||
|
FileStream stream = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
stream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (System.Runtime.Serialization.SerializationException e)
|
||||||
|
{
|
||||||
|
found = false;
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}",
|
||||||
|
filename, id, e.Message, e.StackTrace);
|
||||||
|
|
||||||
|
// If there was a problem deserializing the asset, the asset may
|
||||||
|
// either be corrupted OR was serialized under an old format
|
||||||
|
// {different version of AssetBase} -- we should attempt to
|
||||||
|
// delete it and re-cache
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
found = false;
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}",
|
||||||
|
filename, id, e.Message, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
public AssetBase Get(string id)
|
public AssetBase Get(string id)
|
||||||
{
|
{
|
||||||
m_Requests++;
|
m_Requests++;
|
||||||
|
@ -456,11 +511,26 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Check(string id)
|
||||||
|
{
|
||||||
|
if (m_MemoryCacheEnabled && CheckFromMemoryCache(id))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (m_FileCacheEnabled && CheckFromFileCache(id))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public AssetBase GetCached(string id)
|
public AssetBase GetCached(string id)
|
||||||
{
|
{
|
||||||
return Get(id);
|
return Get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AssetBase CheckCached(string id)
|
||||||
|
{
|
||||||
|
return Get(id);
|
||||||
|
}
|
||||||
|
|
||||||
public void Expire(string id)
|
public void Expire(string id)
|
||||||
{
|
{
|
||||||
if (m_LogLevel >= 2)
|
if (m_LogLevel >= 2)
|
||||||
|
@ -941,6 +1011,11 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
return asset.Data;
|
return asset.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CheckData(string id)
|
||||||
|
{
|
||||||
|
return Check(id); ;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Get(string id, object sender, AssetRetrieved handler)
|
public bool Get(string id, object sender, AssetRetrieved handler)
|
||||||
{
|
{
|
||||||
AssetBase asset = Get(id);
|
AssetBase asset = Get(id);
|
||||||
|
|
|
@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||||
// IImprovedAssetCache
|
// IImprovedAssetCache
|
||||||
//
|
//
|
||||||
|
|
||||||
|
public bool Check(string id)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Cache(AssetBase asset)
|
public void Cache(AssetBase asset)
|
||||||
{
|
{
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
|
|
|
@ -361,6 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
public bool ValidateBakedTextureCache(IScenePresence sp)
|
public bool ValidateBakedTextureCache(IScenePresence sp)
|
||||||
{
|
{
|
||||||
bool defonly = true; // are we only using default textures
|
bool defonly = true; // are we only using default textures
|
||||||
|
IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
|
||||||
|
|
||||||
// Process the texture entry
|
// Process the texture entry
|
||||||
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
|
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
|
||||||
|
@ -385,8 +386,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
|
|
||||||
defonly = false; // found a non-default texture reference
|
defonly = false; // found a non-default texture reference
|
||||||
|
|
||||||
if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
|
if (cache != null)
|
||||||
return false;
|
{
|
||||||
|
if (!cache.Check(face.TextureID.ToString()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
|
// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
|
||||||
|
@ -398,6 +407,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
|
public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
|
||||||
{
|
{
|
||||||
int texturesRebaked = 0;
|
int texturesRebaked = 0;
|
||||||
|
IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
|
||||||
|
|
||||||
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
|
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -421,21 +431,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
|
|
||||||
if (missingTexturesOnly)
|
if (missingTexturesOnly)
|
||||||
{
|
{
|
||||||
if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
|
if (cache != null)
|
||||||
{
|
{
|
||||||
continue;
|
if (cache.Check(face.TextureID.ToString()))
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
|
||||||
|
face.TextureID, idx, sp.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// On inter-simulator teleports, this occurs if baked textures are not being stored by the
|
if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
|
||||||
// grid asset service (which means that they are not available to the new region and so have
|
{
|
||||||
// to be re-requested from the client).
|
continue;
|
||||||
//
|
}
|
||||||
// The only available core OpenSimulator behaviour right now
|
|
||||||
// is not to store these textures, temporarily or otherwise.
|
else
|
||||||
m_log.DebugFormat(
|
{
|
||||||
"[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
|
// On inter-simulator teleports, this occurs if baked textures are not being stored by the
|
||||||
face.TextureID, idx, sp.Name);
|
// grid asset service (which means that they are not available to the new region and so have
|
||||||
|
// to be re-requested from the client).
|
||||||
|
//
|
||||||
|
// The only available core OpenSimulator behaviour right now
|
||||||
|
// is not to store these textures, temporarily or otherwise.
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
|
||||||
|
face.TextureID, idx, sp.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue