From 9aa6389b8ba37715e0b68071040d2a9c488515ad Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 8 Aug 2014 02:22:18 +0100 Subject: lock set appearence during ValidateBakedTextureCache there seems to be a overlap in same cases --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 190 +++++++++++---------- 1 file changed, 97 insertions(+), 93 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/AvatarFactory') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 797ec2b..9b13a09 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -487,131 +487,135 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public bool ValidateBakedTextureCache(IScenePresence sp) { bool defonly = true; // are we only using default textures - IAssetService cache = m_scene.AssetService; - IBakedTextureModule bakedModule = m_scene.RequestModuleInterface(); - WearableCacheItem[] wearableCache = null; - WearableCacheItem[] bakedModuleCache = null; - wearableCache = WearableCacheItem.GetDefaultCacheItem(); + lock (m_setAppearanceLock) + { + IAssetService cache = m_scene.AssetService; + IBakedTextureModule bakedModule = m_scene.RequestModuleInterface(); + WearableCacheItem[] wearableCache = null; + WearableCacheItem[] bakedModuleCache = null; - int hits = 0; - bool gotbacked = false; + wearableCache = WearableCacheItem.GetDefaultCacheItem(); - // Cache wearable data for teleport. - // Only makes sense if there's a bake module and a cache module - if (bakedModule != null && cache != null) - { - m_log.Debug("[ValidateBakedCache] calling bakedModule"); - try - { - bakedModuleCache = bakedModule.Get(sp.UUID); - } - catch (Exception) - { - bakedModuleCache = null; - } + int hits = 0; + bool gotbacked = false; - if (bakedModuleCache != null) + // Cache wearable data for teleport. + // Only makes sense if there's a bake module and a cache module + if (bakedModule != null && cache != null) { - m_log.Debug("[ValidateBakedCache] got bakedModule cache " + bakedModuleCache.Length); + m_log.Debug("[ValidateBakedCache] calling bakedModule"); + try + { + bakedModuleCache = bakedModule.Get(sp.UUID); + } + catch (Exception) + { + bakedModuleCache = null; + } - for (int i = 0; i < bakedModuleCache.Length; i++) + if (bakedModuleCache != null) { - int j = (int)bakedModuleCache[i].TextureIndex; + m_log.Debug("[ValidateBakedCache] got bakedModule cache " + bakedModuleCache.Length); - if (bakedModuleCache[i].TextureAsset != null) + for (int i = 0; i < bakedModuleCache.Length; i++) { - wearableCache[j].TextureID = bakedModuleCache[i].TextureID; - wearableCache[j].CacheId = bakedModuleCache[i].CacheId; - wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset; - bakedModuleCache[i].TextureAsset.Temporary = true; - bakedModuleCache[i].TextureAsset.Local = true; - cache.Store(bakedModuleCache[i].TextureAsset); + int j = (int)bakedModuleCache[i].TextureIndex; + + if (bakedModuleCache[i].TextureAsset != null) + { + wearableCache[j].TextureID = bakedModuleCache[i].TextureID; + wearableCache[j].CacheId = bakedModuleCache[i].CacheId; + wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset; + bakedModuleCache[i].TextureAsset.Temporary = true; + bakedModuleCache[i].TextureAsset.Local = true; + cache.Store(bakedModuleCache[i].TextureAsset); + } } + gotbacked = true; } - gotbacked = true; } - } - // Process the baked textures - for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) - { - int idx = AvatarAppearance.BAKE_INDICES[i]; - Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; - - // on tp viewer assumes servers did the cache work - // and tp propagation of baked textures is broken somewhere - // so make grid cache be mandatory - if (gotbacked) + // Process the baked textures + for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) { -// m_log.Debug("[ValidateBakedCache] bakedModule cache override"); - if(sp.Appearance.Texture.FaceTextures[idx] == null) - sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx); - sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID; - face = sp.Appearance.Texture.FaceTextures[idx]; + int idx = AvatarAppearance.BAKE_INDICES[i]; + Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; - // this should be removed - if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) + // on tp viewer assumes servers did the cache work + // and tp propagation of baked textures is broken somewhere + // so make grid cache be mandatory + if (gotbacked) { - defonly = false; // found a non-default texture reference - } + // m_log.Debug("[ValidateBakedCache] bakedModule cache override"); + if (sp.Appearance.Texture.FaceTextures[idx] == null) + sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx); + sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID; + face = sp.Appearance.Texture.FaceTextures[idx]; + + // this should be removed + if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) + { + defonly = false; // found a non-default texture reference + } - continue; - } - else - { - // No face, so lets check our cache - if (face == null || face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) + continue; + } + else { - sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx); - if (wearableCache[idx].TextureID != UUID.Zero) + // No face, so lets check our cache + if (face == null || face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) { - sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID; - face = sp.Appearance.Texture.FaceTextures[idx]; - // let run to end of loop to check cache + sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx); + if (wearableCache[idx].TextureID != UUID.Zero) + { + sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID; + face = sp.Appearance.Texture.FaceTextures[idx]; + // let run to end of loop to check cache + } + else + { + sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; + face = sp.Appearance.Texture.FaceTextures[idx]; + // lets try not invalidating the cache entry + // wearableCache[idx].CacheId = UUID.Zero; + // wearableCache[idx].TextureAsset = null; + continue; + } } - else + + if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) { - sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; - face = sp.Appearance.Texture.FaceTextures[idx]; - // lets try not invalidating the cache entry - // wearableCache[idx].CacheId = UUID.Zero; - // wearableCache[idx].TextureAsset = null; + defonly = false; // found a non-default texture reference continue; } - } - if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) - { - defonly = false; // found a non-default texture reference - continue; - } - - if (wearableCache[idx].TextureID != face.TextureID) - { - wearableCache[idx].CacheId = UUID.Zero; - wearableCache[idx].TextureID = UUID.Zero; - wearableCache[idx].TextureAsset = null; - continue; - } - - wearableCache[idx].TextureAsset = null; - if (cache != null) - { - wearableCache[idx].TextureAsset = m_scene.AssetService.Get(face.TextureID.ToString()); - if (wearableCache[idx].TextureAsset == null) + if (wearableCache[idx].TextureID != face.TextureID) { wearableCache[idx].CacheId = UUID.Zero; wearableCache[idx].TextureID = UUID.Zero; + wearableCache[idx].TextureAsset = null; + continue; + } + + wearableCache[idx].TextureAsset = null; + if (cache != null) + { + wearableCache[idx].TextureAsset = m_scene.AssetService.Get(face.TextureID.ToString()); + if (wearableCache[idx].TextureAsset == null) + { + wearableCache[idx].CacheId = UUID.Zero; + wearableCache[idx].TextureID = UUID.Zero; + } + else + hits++; } - else - hits++; } } - } - sp.Appearance.WearableCacheItems = wearableCache; + sp.Appearance.WearableCacheItems = wearableCache; + } m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1} {2} {3}", sp.Name, sp.UUID, hits, defonly.ToString()); // debug -- cgit v1.1