mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 04:05:42 +08:00
Merge branch 'master' into httptests
This commit is contained in:
@@ -62,6 +62,7 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private bool m_Enabled;
|
||||
private bool m_Running;
|
||||
|
||||
private const string m_ModuleName = "FlotsamAssetCache";
|
||||
private const string m_DefaultCacheDirectory = "./assetcache";
|
||||
@@ -94,7 +95,7 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
private const double m_DefaultFileExpiration = 48;
|
||||
private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration);
|
||||
private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration);
|
||||
private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(0.166);
|
||||
private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(1.0);
|
||||
|
||||
private static int m_CacheDirectoryTiers = 1;
|
||||
private static int m_CacheDirectoryTierLen = 3;
|
||||
@@ -104,7 +105,8 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
private IAssetService m_AssetService;
|
||||
private List<Scene> m_Scenes = new List<Scene>();
|
||||
|
||||
private object timerLock = new object();
|
||||
|
||||
public FlotsamAssetCache()
|
||||
{
|
||||
m_InvalidChars.AddRange(Path.GetInvalidPathChars());
|
||||
@@ -170,14 +172,6 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory);
|
||||
|
||||
if (m_FileCacheEnabled && (m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero))
|
||||
{
|
||||
m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds);
|
||||
m_CacheCleanTimer.AutoReset = true;
|
||||
m_CacheCleanTimer.Elapsed += CleanupExpiredFiles;
|
||||
lock (m_CacheCleanTimer)
|
||||
m_CacheCleanTimer.Start();
|
||||
}
|
||||
|
||||
if (m_CacheDirectoryTiers < 1)
|
||||
{
|
||||
@@ -219,7 +213,6 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
{
|
||||
scene.RegisterModuleInterface<IImprovedAssetCache>(this);
|
||||
m_Scenes.Add(scene);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,13 +222,39 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
{
|
||||
scene.UnregisterModuleInterface<IImprovedAssetCache>(this);
|
||||
m_Scenes.Remove(scene);
|
||||
lock(timerLock)
|
||||
{
|
||||
if(m_Running && m_Scenes.Count <= 0)
|
||||
{
|
||||
m_Running = false;
|
||||
m_CacheCleanTimer.Stop();
|
||||
m_CacheCleanTimer.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (m_Enabled && m_AssetService == null)
|
||||
m_AssetService = scene.RequestModuleInterface<IAssetService>();
|
||||
if (m_Enabled)
|
||||
{
|
||||
if(m_AssetService == null)
|
||||
m_AssetService = scene.RequestModuleInterface<IAssetService>();
|
||||
lock(timerLock)
|
||||
{
|
||||
if(!m_Running)
|
||||
{
|
||||
if (m_FileCacheEnabled && (m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero))
|
||||
{
|
||||
m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds);
|
||||
m_CacheCleanTimer.AutoReset = false;
|
||||
m_CacheCleanTimer.Elapsed += CleanupExpiredFiles;
|
||||
m_CacheCleanTimer.Start();
|
||||
m_Running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -542,6 +561,8 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
if (m_LogLevel >= 2)
|
||||
m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration);
|
||||
|
||||
if(!m_Running)
|
||||
return;
|
||||
// Purge all files last accessed prior to this point
|
||||
DateTime purgeLine = DateTime.Now - m_FileExpiration;
|
||||
|
||||
@@ -554,6 +575,12 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
{
|
||||
CleanExpiredFiles(dir, purgeLine);
|
||||
}
|
||||
|
||||
lock(timerLock)
|
||||
{
|
||||
if(m_Running)
|
||||
m_CacheCleanTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -789,9 +816,15 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
s.ForEachSOG(delegate(SceneObjectGroup e)
|
||||
{
|
||||
if(!m_Running && !storeUncached)
|
||||
return;
|
||||
|
||||
gatherer.AddForInspection(e);
|
||||
gatherer.GatherAll();
|
||||
|
||||
if(!m_Running && !storeUncached)
|
||||
return;
|
||||
|
||||
foreach (UUID assetID in gatherer.GatheredUuids.Keys)
|
||||
{
|
||||
if (!assetsFound.ContainsKey(assetID))
|
||||
@@ -801,6 +834,7 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
UpdateFileLastAccessTime(filename);
|
||||
assetsFound[assetID] = true;
|
||||
}
|
||||
else if (storeUncached)
|
||||
{
|
||||
@@ -820,7 +854,14 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
}
|
||||
|
||||
gatherer.GatheredUuids.Clear();
|
||||
if(!m_Running && !storeUncached)
|
||||
return;
|
||||
|
||||
if(!storeUncached)
|
||||
Thread.Sleep(50);
|
||||
});
|
||||
if(!m_Running && !storeUncached)
|
||||
break;
|
||||
}
|
||||
|
||||
return assetsFound.Count;
|
||||
@@ -982,7 +1023,27 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
WorkManager.RunInThread(delegate
|
||||
{
|
||||
bool wasRunning= false;
|
||||
lock(timerLock)
|
||||
{
|
||||
if(m_Running)
|
||||
{
|
||||
m_CacheCleanTimer.Stop();
|
||||
m_Running = false;
|
||||
wasRunning = true;
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
int assetReferenceTotal = TouchAllSceneAssets(true);
|
||||
GC.Collect();
|
||||
lock(timerLock)
|
||||
{
|
||||
if(wasRunning)
|
||||
{
|
||||
m_CacheCleanTimer.Start();
|
||||
m_Running = true;
|
||||
}
|
||||
}
|
||||
con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal);
|
||||
}, null, "TouchAllSceneAssets");
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
//m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
|
||||
|
||||
MapBlockData data;
|
||||
if (regionInfos.Count > 0)
|
||||
if (regionInfos != null && regionInfos.Count > 0)
|
||||
{
|
||||
foreach (GridRegion info in regionInfos)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
}
|
||||
|
||||
// final block, closing the search result
|
||||
AddFinalBlock(blocks,mapNameOrig);
|
||||
AddFinalBlock(blocks,mapNameOrig);
|
||||
|
||||
// flags are agent flags sent from the viewer.
|
||||
// they have different values depending on different viewers, apparently
|
||||
|
||||
Reference in New Issue
Block a user