aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2009-08-29 04:35:18 +0100
committerMelanie2009-08-29 04:35:18 +0100
commit4b2e62fd3c347ec4d72762c19443e4a2765582f2 (patch)
tree022ddead005a6167c2ac001703e34cb7ae77bc83
parentFix up WebFetchInventoryDescendents to really return all data needed, (diff)
downloadopensim-SC_OLD-4b2e62fd3c347ec4d72762c19443e4a2765582f2.zip
opensim-SC_OLD-4b2e62fd3c347ec4d72762c19443e4a2765582f2.tar.gz
opensim-SC_OLD-4b2e62fd3c347ec4d72762c19443e4a2765582f2.tar.bz2
opensim-SC_OLD-4b2e62fd3c347ec4d72762c19443e4a2765582f2.tar.xz
Make the j2kDecodeCache expire after 50 minutes (configurable). Alse allows
setting the path for it. This commit introduces NEW DEFAULT BEHAVIOR. To retain the old behavior (eternal cache) you will need to change your OpenSim.ini and set the timeout to 0.
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs28
-rw-r--r--bin/OpenSim.ini.example7
2 files changed, 31 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 0d3cc23..00a247c 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -53,8 +53,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
53 /// </summary> 53 /// </summary>
54 private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>(); 54 private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>();
55 private bool OpenJpegFail = false; 55 private bool OpenJpegFail = false;
56 private readonly string CacheFolder = Util.dataDir() + "/j2kDecodeCache"; 56 private string CacheFolder = Util.dataDir() + "/j2kDecodeCache";
57 private readonly J2KDecodeFileCache fCache; 57 private int CacheTimeout = 60;
58 private J2KDecodeFileCache fCache;
58 59
59 /// <summary> 60 /// <summary>
60 /// List of client methods to notify of results of decode 61 /// List of client methods to notify of results of decode
@@ -63,11 +64,19 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
63 64
64 public J2KDecoderModule() 65 public J2KDecoderModule()
65 { 66 {
66 fCache = new J2KDecodeFileCache(CacheFolder);
67 } 67 }
68 68
69 public void Initialise(Scene scene, IConfigSource source) 69 public void Initialise(Scene scene, IConfigSource source)
70 { 70 {
71 IConfig j2kConfig = source.Configs["J2KDecoder"];
72 if (j2kConfig != null)
73 {
74 CacheFolder = j2kConfig.GetString("CacheDir", CacheFolder);
75 CacheTimeout = j2kConfig.GetInt("CacheTimeout", CacheTimeout);
76 }
77
78 fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout);
79
71 scene.RegisterModuleInterface<IJ2KDecoder>(this); 80 scene.RegisterModuleInterface<IJ2KDecoder>(this);
72 } 81 }
73 82
@@ -353,6 +362,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
353 public class J2KDecodeFileCache 362 public class J2KDecodeFileCache
354 { 363 {
355 private readonly string m_cacheDecodeFolder; 364 private readonly string m_cacheDecodeFolder;
365 private readonly int m_cacheTimeout;
356 private bool enabled = true; 366 private bool enabled = true;
357 367
358 private static readonly ILog m_log 368 private static readonly ILog m_log
@@ -362,9 +372,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
362 /// Creates a new instance of a file cache 372 /// Creates a new instance of a file cache
363 /// </summary> 373 /// </summary>
364 /// <param name="pFolder">base folder for the cache. Will be created if it doesn't exist</param> 374 /// <param name="pFolder">base folder for the cache. Will be created if it doesn't exist</param>
365 public J2KDecodeFileCache(string pFolder) 375 public J2KDecodeFileCache(string pFolder, int timeout)
366 { 376 {
367 m_cacheDecodeFolder = pFolder; 377 m_cacheDecodeFolder = pFolder;
378 m_cacheTimeout = timeout;
368 if (!Directory.Exists(pFolder)) 379 if (!Directory.Exists(pFolder))
369 { 380 {
370 Createj2KCacheFolder(pFolder); 381 Createj2KCacheFolder(pFolder);
@@ -426,6 +437,15 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
426 return false; 437 return false;
427 } 438 }
428 439
440 DateTime creationTime = File.GetCreationTime(filename);
441 TimeSpan fileAge = DateTime.Now - creationTime;
442
443 if (m_cacheTimeout != 0 && fileAge >= TimeSpan.FromMinutes(m_cacheTimeout))
444 {
445 File.Delete(filename);
446 return false;
447 }
448
429 string readResult = string.Empty; 449 string readResult = string.Empty;
430 450
431 try 451 try
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index cff5d19..3529599 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -1366,6 +1366,13 @@
1366 ; 1366 ;
1367 ;TextureDataLimit = 5 1367 ;TextureDataLimit = 5
1368 1368
1369;; The JPEG2000 decode cache
1370;; Timeout is in minutes
1371
1372[J2KDecoder]
1373;CacheDir = "./j2kDecodeCache"
1374;CacheTimeout = 60
1375
1369;; 1376;;
1370;; These are defaults that are overwritten below in [Architecture]. 1377;; These are defaults that are overwritten below in [Architecture].
1371;; These defaults allow OpenSim to work out of the box with 1378;; These defaults allow OpenSim to work out of the box with