aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorUbitUmarov2012-12-13 02:55:36 +0000
committerUbitUmarov2012-12-13 02:55:36 +0000
commit20773dcfccc04d8af14e27f87746711bfaba07b1 (patch)
treeb1428733102b796e1fd87e204da4d24b9f66b670 /OpenSim/Region/CoreModules
parentmake ubitODE ignore X and Y rotation components on avatar rotations (diff)
downloadopensim-SC-20773dcfccc04d8af14e27f87746711bfaba07b1.zip
opensim-SC-20773dcfccc04d8af14e27f87746711bfaba07b1.tar.gz
opensim-SC-20773dcfccc04d8af14e27f87746711bfaba07b1.tar.bz2
opensim-SC-20773dcfccc04d8af14e27f87746711bfaba07b1.tar.xz
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*
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs6
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs75
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs51
5 files changed, 128 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index e40caec..f43305f 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -194,6 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset
194 194
195 #region IImprovedAssetCache Members 195 #region IImprovedAssetCache Members
196 196
197
198 public bool Check(string id)
199 {
200 return false;
201 }
202
197 /// <summary> 203 /// <summary>
198 /// Cache asset. 204 /// Cache asset.
199 /// </summary> 205 /// </summary>
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 9742a5c..58ce61a 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -112,6 +112,10 @@ namespace OpenSim.Region.CoreModules.Asset
112 //////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////
113 // IImprovedAssetCache 113 // IImprovedAssetCache
114 // 114 //
115 public bool Check(string id)
116 {
117 return false;
118 }
115 119
116 public void Cache(AssetBase asset) 120 public void Cache(AssetBase asset)
117 { 121 {
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index b1bb56b..a0f1e8c 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -348,6 +348,17 @@ namespace OpenSim.Region.CoreModules.Asset
348 return asset; 348 return asset;
349 } 349 }
350 350
351 private bool CheckFromMemoryCache(string id)
352 {
353 AssetBase asset = null;
354
355 if (m_MemoryCache.TryGetValue(id, out asset))
356 return true;
357
358 return false;
359 }
360
361
351 /// <summary> 362 /// <summary>
352 /// Try to get an asset from the file cache. 363 /// Try to get an asset from the file cache.
353 /// </summary> 364 /// </summary>
@@ -420,6 +431,50 @@ namespace OpenSim.Region.CoreModules.Asset
420 return asset; 431 return asset;
421 } 432 }
422 433
434 private bool CheckFromFileCache(string id)
435 {
436 bool found = false;
437
438 string filename = GetFileName(id);
439 if (File.Exists(filename))
440 {
441 // actually check if we can open it, and so update expire
442 FileStream stream = null;
443 try
444 {
445 stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
446 if (stream != null)
447 {
448 found = true;
449 stream.Close();
450 }
451
452 }
453 catch (System.Runtime.Serialization.SerializationException e)
454 {
455 found = false;
456 m_log.ErrorFormat(
457 "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}",
458 filename, id, e.Message, e.StackTrace);
459
460 // If there was a problem deserializing the asset, the asset may
461 // either be corrupted OR was serialized under an old format
462 // {different version of AssetBase} -- we should attempt to
463 // delete it and re-cache
464 File.Delete(filename);
465 }
466 catch (Exception e)
467 {
468 found = false;
469 m_log.ErrorFormat(
470 "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}",
471 filename, id, e.Message, e.StackTrace);
472 }
473 }
474
475 return found;
476 }
477
423 public AssetBase Get(string id) 478 public AssetBase Get(string id)
424 { 479 {
425 m_Requests++; 480 m_Requests++;
@@ -456,11 +511,26 @@ namespace OpenSim.Region.CoreModules.Asset
456 return asset; 511 return asset;
457 } 512 }
458 513
514 public bool Check(string id)
515 {
516 if (m_MemoryCacheEnabled && CheckFromMemoryCache(id))
517 return true;
518
519 if (m_FileCacheEnabled && CheckFromFileCache(id))
520 return true;
521 return false;
522 }
523
459 public AssetBase GetCached(string id) 524 public AssetBase GetCached(string id)
460 { 525 {
461 return Get(id); 526 return Get(id);
462 } 527 }
463 528
529 public AssetBase CheckCached(string id)
530 {
531 return Get(id);
532 }
533
464 public void Expire(string id) 534 public void Expire(string id)
465 { 535 {
466 if (m_LogLevel >= 2) 536 if (m_LogLevel >= 2)
@@ -941,6 +1011,11 @@ namespace OpenSim.Region.CoreModules.Asset
941 return asset.Data; 1011 return asset.Data;
942 } 1012 }
943 1013
1014 public bool CheckData(string id)
1015 {
1016 return Check(id); ;
1017 }
1018
944 public bool Get(string id, object sender, AssetRetrieved handler) 1019 public bool Get(string id, object sender, AssetRetrieved handler)
945 { 1020 {
946 AssetBase asset = Get(id); 1021 AssetBase asset = Get(id);
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index 9592ca0..ce9b546 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset
115 // IImprovedAssetCache 115 // IImprovedAssetCache
116 // 116 //
117 117
118 public bool Check(string id)
119 {
120 return false;
121 }
122
118 public void Cache(AssetBase asset) 123 public void Cache(AssetBase asset)
119 { 124 {
120 if (asset != null) 125 if (asset != null)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 4c42397..3532b1d 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -361,6 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
361 public bool ValidateBakedTextureCache(IScenePresence sp) 361 public bool ValidateBakedTextureCache(IScenePresence sp)
362 { 362 {
363 bool defonly = true; // are we only using default textures 363 bool defonly = true; // are we only using default textures
364 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
364 365
365 // Process the texture entry 366 // Process the texture entry
366 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 367 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
@@ -385,8 +386,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
385 386
386 defonly = false; // found a non-default texture reference 387 defonly = false; // found a non-default texture reference
387 388
388 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 389 if (cache != null)
389 return false; 390 {
391 if (!cache.Check(face.TextureID.ToString()))
392 return false;
393 }
394 else
395 {
396 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
397 return false;
398 }
390 } 399 }
391 400
392// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 401// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
@@ -398,6 +407,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
398 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) 407 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
399 { 408 {
400 int texturesRebaked = 0; 409 int texturesRebaked = 0;
410 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
401 411
402 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 412 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
403 { 413 {
@@ -421,21 +431,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
421 431
422 if (missingTexturesOnly) 432 if (missingTexturesOnly)
423 { 433 {
424 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) 434 if (cache != null)
425 { 435 {
426 continue; 436 if (cache.Check(face.TextureID.ToString()))
437 continue;
438 else
439 {
440 m_log.DebugFormat(
441 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
442 face.TextureID, idx, sp.Name);
443 }
427 } 444 }
428 else 445 else
429 { 446 {
430 // On inter-simulator teleports, this occurs if baked textures are not being stored by the 447 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
431 // grid asset service (which means that they are not available to the new region and so have 448 {
432 // to be re-requested from the client). 449 continue;
433 // 450 }
434 // The only available core OpenSimulator behaviour right now 451
435 // is not to store these textures, temporarily or otherwise. 452 else
436 m_log.DebugFormat( 453 {
437 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", 454 // On inter-simulator teleports, this occurs if baked textures are not being stored by the
438 face.TextureID, idx, sp.Name); 455 // grid asset service (which means that they are not available to the new region and so have
456 // to be re-requested from the client).
457 //
458 // The only available core OpenSimulator behaviour right now
459 // is not to store these textures, temporarily or otherwise.
460 m_log.DebugFormat(
461 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
462 face.TextureID, idx, sp.Name);
463 }
439 } 464 }
440 } 465 }
441 else 466 else