diff options
author | Oren Hurvitz | 2014-01-29 16:14:27 +0200 |
---|---|---|
committer | Oren Hurvitz | 2014-03-25 08:01:55 +0100 |
commit | e131e73652cf6ed2407e41c7d83dc67f49ca23ee (patch) | |
tree | e0d8573e47c8edd7f2effca8d4177bc57bd10a26 /OpenSim | |
parent | Changed LogThreadPool to have 4 logging levels. Added console command "debug ... (diff) | |
download | opensim-SC_OLD-e131e73652cf6ed2407e41c7d83dc67f49ca23ee.zip opensim-SC_OLD-e131e73652cf6ed2407e41c7d83dc67f49ca23ee.tar.gz opensim-SC_OLD-e131e73652cf6ed2407e41c7d83dc67f49ca23ee.tar.bz2 opensim-SC_OLD-e131e73652cf6ed2407e41c7d83dc67f49ca23ee.tar.xz |
Run slow operations in a separate thread, instead of using FireAndForget (which has a 1-minute timeout)
Resolves http://opensimulator.org/mantis/view.php?id=6945
Diffstat (limited to 'OpenSim')
7 files changed, 35 insertions, 12 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index b39dc5f..c9930fb 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -2320,6 +2320,29 @@ namespace OpenSim.Framework | |||
2320 | #endregion FireAndForget Threading Pattern | 2320 | #endregion FireAndForget Threading Pattern |
2321 | 2321 | ||
2322 | /// <summary> | 2322 | /// <summary> |
2323 | /// Run the callback on a different thread, outside the thread pool. This is used for tasks | ||
2324 | /// that may take a long time. | ||
2325 | /// </summary> | ||
2326 | public static void RunThreadNoTimeout(WaitCallback callback, string name, object obj) | ||
2327 | { | ||
2328 | Thread t = new Thread(delegate() | ||
2329 | { | ||
2330 | try | ||
2331 | { | ||
2332 | Culture.SetCurrentCulture(); | ||
2333 | callback(obj); | ||
2334 | } | ||
2335 | catch (Exception e) | ||
2336 | { | ||
2337 | m_log.Error("Exception in thread " + name, e); | ||
2338 | } | ||
2339 | }); | ||
2340 | |||
2341 | t.Name = name; | ||
2342 | t.Start(); | ||
2343 | } | ||
2344 | |||
2345 | /// <summary> | ||
2323 | /// Environment.TickCount is an int but it counts all 32 bits so it goes positive | 2346 | /// Environment.TickCount is an int but it counts all 32 bits so it goes positive |
2324 | /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap | 2347 | /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap |
2325 | /// for the callers. | 2348 | /// for the callers. |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 4292719..d15703e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -356,7 +356,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
356 | m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, | 356 | m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, |
357 | options, ReceivedAllAssets); | 357 | options, ReceivedAllAssets); |
358 | 358 | ||
359 | Util.FireAndForget(o => ar.Execute()); | 359 | Util.RunThreadNoTimeout(o => ar.Execute(), "AssetsRequest", null); |
360 | } | 360 | } |
361 | else | 361 | else |
362 | { | 362 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 99913a9..6832b1f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -193,12 +193,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
193 | // Protect ourselves against the caller subsequently modifying the items list | 193 | // Protect ourselves against the caller subsequently modifying the items list |
194 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); | 194 | List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); |
195 | 195 | ||
196 | Util.FireAndForget(delegate | 196 | Util.RunThreadNoTimeout(delegate |
197 | { | 197 | { |
198 | foreach (InventoryItemBase item in items) | 198 | foreach (InventoryItemBase item in items) |
199 | if (!string.IsNullOrEmpty(item.CreatorData)) | 199 | if (!string.IsNullOrEmpty(item.CreatorData)) |
200 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); | 200 | UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); |
201 | }); | 201 | }, "GetFolderContent", null); |
202 | } | 202 | } |
203 | 203 | ||
204 | return invCol; | 204 | return invCol; |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index cd95ee9..136a16e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
199 | m_rootScene.AssetService, m_rootScene.UserAccountService, | 199 | m_rootScene.AssetService, m_rootScene.UserAccountService, |
200 | m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets); | 200 | m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets); |
201 | 201 | ||
202 | Util.FireAndForget(o => ar.Execute()); | 202 | Util.RunThreadNoTimeout(o => ar.Execute(), "AssetsRequest", null); |
203 | 203 | ||
204 | // CloseArchive() will be called from ReceivedAllAssets() | 204 | // CloseArchive() will be called from ReceivedAllAssets() |
205 | } | 205 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 2d0da61..4f428c3 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
143 | m_requestState = RequestState.Running; | 143 | m_requestState = RequestState.Running; |
144 | 144 | ||
145 | m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} possible assets", m_repliesRequired); | 145 | m_log.DebugFormat("[ARCHIVER]: AssetsRequest executed looking for {0} possible assets", m_repliesRequired); |
146 | 146 | ||
147 | // We can stop here if there are no assets to fetch | 147 | // We can stop here if there are no assets to fetch |
148 | if (m_repliesRequired == 0) | 148 | if (m_repliesRequired == 0) |
149 | { | 149 | { |
@@ -226,7 +226,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
226 | finally | 226 | finally |
227 | { | 227 | { |
228 | if (timedOut) | 228 | if (timedOut) |
229 | Util.FireAndForget(PerformAssetsRequestCallback, true); | 229 | Util.RunThreadNoTimeout(PerformAssetsRequestCallback, "AssetsRequestCallback", true); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
@@ -295,7 +295,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
295 | 295 | ||
296 | // We want to stop using the asset cache thread asap | 296 | // We want to stop using the asset cache thread asap |
297 | // as we now need to do the work of producing the rest of the archive | 297 | // as we now need to do the work of producing the rest of the archive |
298 | Util.FireAndForget(PerformAssetsRequestCallback, false); | 298 | Util.RunThreadNoTimeout(PerformAssetsRequestCallback, "AssetsRequestCallback", false); |
299 | } | 299 | } |
300 | else | 300 | else |
301 | { | 301 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 51f6c5e..726d8e2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1509,7 +1509,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1509 | { | 1509 | { |
1510 | tmpMS = Util.EnvironmentTickCount(); | 1510 | tmpMS = Util.EnvironmentTickCount(); |
1511 | m_cleaningTemps = true; | 1511 | m_cleaningTemps = true; |
1512 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | 1512 | Util.RunThreadNoTimeout(delegate { CleanTempObjects(); m_cleaningTemps = false; }, "CleanTempObjects", null); |
1513 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS); | 1513 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS); |
1514 | } | 1514 | } |
1515 | 1515 | ||
@@ -1682,7 +1682,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1682 | if (!m_backingup) | 1682 | if (!m_backingup) |
1683 | { | 1683 | { |
1684 | m_backingup = true; | 1684 | m_backingup = true; |
1685 | Util.FireAndForget(BackupWaitCallback); | 1685 | Util.RunThreadNoTimeout(BackupWaitCallback, "BackupWaitCallback", null); |
1686 | } | 1686 | } |
1687 | } | 1687 | } |
1688 | 1688 | ||
@@ -1695,7 +1695,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1695 | } | 1695 | } |
1696 | 1696 | ||
1697 | /// <summary> | 1697 | /// <summary> |
1698 | /// Wrapper for Backup() that can be called with Util.FireAndForget() | 1698 | /// Wrapper for Backup() that can be called with Util.RunThreadNoTimeout() |
1699 | /// </summary> | 1699 | /// </summary> |
1700 | private void BackupWaitCallback(object o) | 1700 | private void BackupWaitCallback(object o) |
1701 | { | 1701 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 64c464d..080cdb4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3201,7 +3201,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | public void SendInitialDataToMe() | 3201 | public void SendInitialDataToMe() |
3202 | { | 3202 | { |
3203 | // Send all scene object to the new client | 3203 | // Send all scene object to the new client |
3204 | Util.FireAndForget(delegate | 3204 | Util.RunThreadNoTimeout(delegate |
3205 | { | 3205 | { |
3206 | // we created a new ScenePresence (a new child agent) in a fresh region. | 3206 | // we created a new ScenePresence (a new child agent) in a fresh region. |
3207 | // Request info about all the (root) agents in this region | 3207 | // Request info about all the (root) agents in this region |
@@ -3216,7 +3216,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3216 | ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); | 3216 | ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | }); | 3219 | }, "SendInitialDataToMe", null); |
3220 | } | 3220 | } |
3221 | 3221 | ||
3222 | /// <summary> | 3222 | /// <summary> |