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
OpenSim/Services/FSAssetService
|
@ -76,6 +76,9 @@ namespace OpenSim.Services.FSAssetService
|
||||||
protected int m_missingAssetsFS = 0;
|
protected int m_missingAssetsFS = 0;
|
||||||
protected string m_FSBase;
|
protected string m_FSBase;
|
||||||
|
|
||||||
|
private static bool m_Initialized;
|
||||||
|
private bool m_MainInstance;
|
||||||
|
|
||||||
public FSAssetConnector(IConfigSource config)
|
public FSAssetConnector(IConfigSource config)
|
||||||
: this(config, "AssetService")
|
: this(config, "AssetService")
|
||||||
{
|
{
|
||||||
|
@ -83,6 +86,11 @@ namespace OpenSim.Services.FSAssetService
|
||||||
|
|
||||||
public FSAssetConnector(IConfigSource config, string configName) : base(config)
|
public FSAssetConnector(IConfigSource config, string configName) : base(config)
|
||||||
{
|
{
|
||||||
|
if (!m_Initialized)
|
||||||
|
{
|
||||||
|
m_Initialized = true;
|
||||||
|
m_MainInstance = true;
|
||||||
|
|
||||||
MainConsole.Instance.Commands.AddCommand("fs", false,
|
MainConsole.Instance.Commands.AddCommand("fs", false,
|
||||||
"show assets", "show assets", "Show asset stats",
|
"show assets", "show assets", "Show asset stats",
|
||||||
HandleShowAssets);
|
HandleShowAssets);
|
||||||
|
@ -101,6 +109,7 @@ namespace OpenSim.Services.FSAssetService
|
||||||
"force import", "force import <conn> <table> [<start> <count>]",
|
"force import", "force import <conn> <table> [<start> <count>]",
|
||||||
"Import legacy assets, overwriting current content",
|
"Import legacy assets, overwriting current content",
|
||||||
HandleImportAssets);
|
HandleImportAssets);
|
||||||
|
}
|
||||||
|
|
||||||
IConfig assetConfig = config.Configs[configName];
|
IConfig assetConfig = config.Configs[configName];
|
||||||
|
|
||||||
|
@ -173,6 +182,8 @@ namespace OpenSim.Services.FSAssetService
|
||||||
throw new Exception("Configuration error");
|
throw new Exception("Configuration error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_MainInstance)
|
||||||
|
{
|
||||||
string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty);
|
string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty);
|
||||||
if (loader != string.Empty)
|
if (loader != string.Empty)
|
||||||
{
|
{
|
||||||
|
@ -185,7 +196,6 @@ namespace OpenSim.Services.FSAssetService
|
||||||
Store(a, false);
|
Store(a, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
m_log.Info("[FSASSETS]: FS asset service enabled");
|
|
||||||
|
|
||||||
m_WriterThread = new Thread(Writer);
|
m_WriterThread = new Thread(Writer);
|
||||||
m_WriterThread.Start();
|
m_WriterThread.Start();
|
||||||
|
@ -193,6 +203,9 @@ namespace OpenSim.Services.FSAssetService
|
||||||
m_StatsThread.Start();
|
m_StatsThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_log.Info("[FSASSETS]: FS asset service enabled");
|
||||||
|
}
|
||||||
|
|
||||||
private void Stats()
|
private void Stats()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
|
Loading…
Reference in New Issue