diff options
author | AliciaRaven | 2015-07-13 12:21:10 +0100 |
---|---|---|
committer | Melanie Thielker | 2015-07-13 19:04:33 +0200 |
commit | 248c0e18de1a95120e1f1700345ae8ba03624447 (patch) | |
tree | 1189b9696062d7cba1e6107aa50ac14a210d112b /OpenSim/Services/FSAssetService/FSAssetService.cs | |
parent | Fixed the whitespace in Scene.cs (diff) | |
download | opensim-SC-248c0e18de1a95120e1f1700345ae8ba03624447.zip opensim-SC-248c0e18de1a95120e1f1700345ae8ba03624447.tar.gz opensim-SC-248c0e18de1a95120e1f1700345ae8ba03624447.tar.bz2 opensim-SC-248c0e18de1a95120e1f1700345ae8ba03624447.tar.xz |
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>
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/FSAssetService/FSAssetService.cs | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/OpenSim/Services/FSAssetService/FSAssetService.cs b/OpenSim/Services/FSAssetService/FSAssetService.cs index 8276f33..04f6d79 100644 --- a/OpenSim/Services/FSAssetService/FSAssetService.cs +++ b/OpenSim/Services/FSAssetService/FSAssetService.cs | |||
@@ -76,6 +76,9 @@ namespace OpenSim.Services.FSAssetService | |||
76 | protected int m_missingAssetsFS = 0; | 76 | protected int m_missingAssetsFS = 0; |
77 | protected string m_FSBase; | 77 | protected string m_FSBase; |
78 | 78 | ||
79 | private static bool m_Initialized; | ||
80 | private bool m_MainInstance; | ||
81 | |||
79 | public FSAssetConnector(IConfigSource config) | 82 | public FSAssetConnector(IConfigSource config) |
80 | : this(config, "AssetService") | 83 | : this(config, "AssetService") |
81 | { | 84 | { |
@@ -83,24 +86,30 @@ namespace OpenSim.Services.FSAssetService | |||
83 | 86 | ||
84 | public FSAssetConnector(IConfigSource config, string configName) : base(config) | 87 | public FSAssetConnector(IConfigSource config, string configName) : base(config) |
85 | { | 88 | { |
86 | MainConsole.Instance.Commands.AddCommand("fs", false, | 89 | if (!m_Initialized) |
87 | "show assets", "show assets", "Show asset stats", | 90 | { |
88 | HandleShowAssets); | 91 | m_Initialized = true; |
89 | MainConsole.Instance.Commands.AddCommand("fs", false, | 92 | m_MainInstance = true; |
90 | "show digest", "show digest <ID>", "Show asset digest", | 93 | |
91 | HandleShowDigest); | 94 | MainConsole.Instance.Commands.AddCommand("fs", false, |
92 | MainConsole.Instance.Commands.AddCommand("fs", false, | 95 | "show assets", "show assets", "Show asset stats", |
93 | "delete asset", "delete asset <ID>", | 96 | HandleShowAssets); |
94 | "Delete asset from database", | 97 | MainConsole.Instance.Commands.AddCommand("fs", false, |
95 | HandleDeleteAsset); | 98 | "show digest", "show digest <ID>", "Show asset digest", |
96 | MainConsole.Instance.Commands.AddCommand("fs", false, | 99 | HandleShowDigest); |
97 | "import", "import <conn> <table> [<start> <count>]", | 100 | MainConsole.Instance.Commands.AddCommand("fs", false, |
98 | "Import legacy assets", | 101 | "delete asset", "delete asset <ID>", |
99 | HandleImportAssets); | 102 | "Delete asset from database", |
100 | MainConsole.Instance.Commands.AddCommand("fs", false, | 103 | HandleDeleteAsset); |
101 | "force import", "force import <conn> <table> [<start> <count>]", | 104 | MainConsole.Instance.Commands.AddCommand("fs", false, |
102 | "Import legacy assets, overwriting current content", | 105 | "import", "import <conn> <table> [<start> <count>]", |
103 | HandleImportAssets); | 106 | "Import legacy assets", |
107 | HandleImportAssets); | ||
108 | MainConsole.Instance.Commands.AddCommand("fs", false, | ||
109 | "force import", "force import <conn> <table> [<start> <count>]", | ||
110 | "Import legacy assets, overwriting current content", | ||
111 | HandleImportAssets); | ||
112 | } | ||
104 | 113 | ||
105 | IConfig assetConfig = config.Configs[configName]; | 114 | IConfig assetConfig = config.Configs[configName]; |
106 | 115 | ||
@@ -173,24 +182,28 @@ namespace OpenSim.Services.FSAssetService | |||
173 | throw new Exception("Configuration error"); | 182 | throw new Exception("Configuration error"); |
174 | } | 183 | } |
175 | 184 | ||
176 | string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty); | 185 | if (m_MainInstance) |
177 | if (loader != string.Empty) | ||
178 | { | 186 | { |
179 | m_AssetLoader = LoadPlugin<IAssetLoader>(loader); | 187 | string loader = assetConfig.GetString("DefaultAssetLoader", string.Empty); |
180 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string.Empty); | 188 | if (loader != string.Empty) |
181 | m_log.InfoFormat("[FSASSETS]: Loading default asset set from {0}", loaderArgs); | 189 | { |
182 | m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, | 190 | m_AssetLoader = LoadPlugin<IAssetLoader>(loader); |
183 | delegate(AssetBase a) | 191 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string.Empty); |
184 | { | 192 | m_log.InfoFormat("[FSASSETS]: Loading default asset set from {0}", loaderArgs); |
185 | Store(a, false); | 193 | m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, |
186 | }); | 194 | delegate(AssetBase a) |
195 | { | ||
196 | Store(a, false); | ||
197 | }); | ||
198 | } | ||
199 | |||
200 | m_WriterThread = new Thread(Writer); | ||
201 | m_WriterThread.Start(); | ||
202 | m_StatsThread = new Thread(Stats); | ||
203 | m_StatsThread.Start(); | ||
187 | } | 204 | } |
205 | |||
188 | m_log.Info("[FSASSETS]: FS asset service enabled"); | 206 | m_log.Info("[FSASSETS]: FS asset service enabled"); |
189 | |||
190 | m_WriterThread = new Thread(Writer); | ||
191 | m_WriterThread.Start(); | ||
192 | m_StatsThread = new Thread(Stats); | ||
193 | m_StatsThread.Start(); | ||
194 | } | 207 | } |
195 | 208 | ||
196 | private void Stats() | 209 | private void Stats() |