aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2009-08-29 05:29:54 +0100
committerMelanie2009-08-29 05:29:54 +0100
commit2a5b9f77408bfb0fd4e28e7bf28f59894525c365 (patch)
treeba4824c8688b88345c6c2f5ec77021f20037fa39 /OpenSim
parentMake the j2kDecodeCache expire after 50 minutes (configurable). Alse allows (diff)
downloadopensim-SC_OLD-2a5b9f77408bfb0fd4e28e7bf28f59894525c365.zip
opensim-SC_OLD-2a5b9f77408bfb0fd4e28e7bf28f59894525c365.tar.gz
opensim-SC_OLD-2a5b9f77408bfb0fd4e28e7bf28f59894525c365.tar.bz2
opensim-SC_OLD-2a5b9f77408bfb0fd4e28e7bf28f59894525c365.tar.xz
the beginning of some changes to the decode cache to address concerns about
system load. This commit effectively disables expiration.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs39
1 files changed, 30 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 00a247c..df321a2 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -41,6 +41,8 @@ using OpenSim.Region.Framework.Scenes;
41 41
42namespace OpenSim.Region.CoreModules.Agent.TextureSender 42namespace OpenSim.Region.CoreModules.Agent.TextureSender
43{ 43{
44 public delegate void J2KDecodeDelegate(UUID AssetId);
45
44 public class J2KDecoderModule : IRegionModule, IJ2KDecoder 46 public class J2KDecoderModule : IRegionModule, IJ2KDecoder
45 { 47 {
46 #region IRegionModule Members 48 #region IRegionModule Members
@@ -437,15 +439,6 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
437 return false; 439 return false;
438 } 440 }
439 441
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
449 string readResult = string.Empty; 442 string readResult = string.Empty;
450 443
451 try 444 try
@@ -575,6 +568,16 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
575 return String.Format("j2kCache_{0}.cache", AssetId); 568 return String.Format("j2kCache_{0}.cache", AssetId);
576 } 569 }
577 570
571 public UUID AssetIdFromFileName(string fileName)
572 {
573 string rawId = fileName.Replace("j2kCache_", "").Replace(".cache", "");
574 UUID asset;
575 if (!UUID.TryParse(rawId, out asset))
576 return UUID.Zero;
577
578 return asset;
579 }
580
578 /// <summary> 581 /// <summary>
579 /// Creates the Cache Folder 582 /// Creates the Cache Folder
580 /// </summary> 583 /// </summary>
@@ -639,5 +642,23 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
639 enabled = false; 642 enabled = false;
640 } 643 }
641 } 644 }
645
646 public void ScanCacheFiles(J2KDecodeDelegate decode)
647 {
648 DirectoryInfo dir = new DirectoryInfo(m_cacheDecodeFolder);
649 FileInfo[] files = dir.GetFiles("j2kCache_*.cache");
650
651 foreach (FileInfo f in files)
652 {
653 TimeSpan fileAge = DateTime.Now - f.CreationTime;
654
655 if (m_cacheTimeout != 0 && fileAge >= TimeSpan.FromMinutes(m_cacheTimeout))
656 {
657 File.Delete(f.Name);
658 decode(AssetIdFromFileName(f.Name));
659 System.Threading.Thread.Sleep(2000);
660 }
661 }
662 }
642 } 663 }
643} 664}