Prevent multiple instances of the FSAssets service causing problems. Protect against secondary instances registering duplicate console commands Also prevents multiple instances each starting a writer thread which will cause major file access exceptions as they fight over the contents of the spool directory.
Signed-off-by: Melanie Thielker <melanie@t-data.com>0.8.2-post-fixes
parent
e174dc87fb
commit
248c0e18de
|
@ -76,6 +76,9 @@ namespace OpenSim.Services.FSAssetService
|
|||
protected int m_missingAssetsFS = 0;
|
||||
protected string m_FSBase;
|
||||
|
||||
private static bool m_Initialized;
|
||||
private bool m_MainInstance;
|
||||
|
||||
public FSAssetConnector(IConfigSource config)
|
||||
: this(config, "AssetService")
|
||||
{
|
||||
|
@ -83,6 +86,11 @@ namespace OpenSim.Services.FSAssetService
|
|||
|
||||
public FSAssetConnector(IConfigSource config, string configName) : base(config)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
{
|
||||
m_Initialized = true;
|
||||
m_MainInstance = true;
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("fs", false,
|
||||
"show assets", "show assets", "Show asset stats",
|
||||
HandleShowAssets);
|
||||
|
@ -101,6 +109,7 @@ namespace OpenSim.Services.FSAssetService
|
|||
"force import", "force import <conn> <table> [<start> <count>]",
|
||||
"Import legacy assets, overwriting current content",
|
||||
HandleImportAssets);
|
||||
}
|
||||
|
||||
IConfig assetConfig = config.Configs[configName];
|
||||
|
||||
|
@ -173,6 +182,8 @@ namespace OpenSim.Services.FSAssetService
|
|||
throw new Exception("Configuration error");
|
||||
}
|
||||
|
||||
if (m_MainInstance)
|
||||
{
|
||||
string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty);
|
||||
if (loader != string.Empty)
|
||||
{
|
||||
|
@ -185,7 +196,6 @@ namespace OpenSim.Services.FSAssetService
|
|||
Store(a, false);
|
||||
});
|
||||
}
|
||||
m_log.Info("[FSASSETS]: FS asset service enabled");
|
||||
|
||||
m_WriterThread = new Thread(Writer);
|
||||
m_WriterThread.Start();
|
||||
|
@ -193,6 +203,9 @@ namespace OpenSim.Services.FSAssetService
|
|||
m_StatsThread.Start();
|
||||
}
|
||||
|
||||
m_log.Info("[FSASSETS]: FS asset service enabled");
|
||||
}
|
||||
|
||||
private void Stats()
|
||||
{
|
||||
while (true)
|
||||
|
|
Loading…
Reference in New Issue