From d2f4ca0dfed69637892c2346fa87c88f08c9b8e5 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 23 Aug 2012 21:23:16 +0300 Subject: If Save OAR/IAR times-out while waiting for assets then notify the caller that the operation failed --- .../Archiver/InventoryArchiveWriteRequest.cs | 10 ++++++-- .../World/Archiver/ArchiveWriteRequest.cs | 28 +++++++++++++++------- .../CoreModules/World/Archiver/AssetsArchiver.cs | 7 ------ .../CoreModules/World/Archiver/AssetsRequest.cs | 18 +++++++------- 4 files changed, 37 insertions(+), 26 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index d0e88f6..4c85637 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver SaveAssets = true; } - protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) + protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids, bool timedOut) { Exception reportedException = null; bool succeeded = true; @@ -143,6 +143,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_saveStream.Close(); } + if (timedOut) + { + succeeded = false; + reportedException = new Exception("Loading assets timed out"); + } + m_module.TriggerInventoryArchiveSaved( m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); } @@ -350,7 +356,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { m_log.DebugFormat("[INVENTORY ARCHIVER]: Not saving assets since --noassets was specified"); - ReceivedAllAssets(new List(), new List()); + ReceivedAllAssets(new List(), new List(), false); } } catch (Exception) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 7bdd65c..367693d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs @@ -587,19 +587,29 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } - protected void ReceivedAllAssets( - ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) + protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids, bool timedOut) { - foreach (UUID uuid in assetsNotFoundUuids) + string errorMessage; + + if (timedOut) { - m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); + errorMessage = "Loading assets timed out"; } + else + { + foreach (UUID uuid in assetsNotFoundUuids) + { + m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); + } - // m_log.InfoFormat( - // "[ARCHIVER]: Received {0} of {1} assets requested", - // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); + // m_log.InfoFormat( + // "[ARCHIVER]: Received {0} of {1} assets requested", + // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); - CloseArchive(String.Empty); + errorMessage = String.Empty; + } + + CloseArchive(errorMessage); } /// @@ -626,4 +636,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs index 95d109c..c1ff94d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsArchiver.cs @@ -150,12 +150,5 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Added {0} assets to archive", m_assetsWritten); } - /// - /// Only call this if you need to force a close on the underlying writer. - /// - public void ForceClose() - { - m_archiveWriter.Close(); - } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 103eb47..b22bcf9 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// Method called when all the necessary assets for an archive request have been received. /// public delegate void AssetsRequestCallback( - ICollection assetsFoundUuids, ICollection assetsNotFoundUuids); + ICollection assetsFoundUuids, ICollection assetsNotFoundUuids, bool timedOut); enum RequestState { @@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver if (m_repliesRequired == 0) { m_requestState = RequestState.Completed; - PerformAssetsRequestCallback(null); + PerformAssetsRequestCallback(false); return; } @@ -164,7 +164,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args) { - bool close = true; + bool timedOut = true; try { @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver // the final request came in (assuming that such a thing is possible) if (m_requestState == RequestState.Completed) { - close = false; + timedOut = false; return; } @@ -223,8 +223,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver } finally { - if (close) - m_assetsArchiver.ForceClose(); + if (timedOut) + Util.FireAndForget(PerformAssetsRequestCallback, true); } } @@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver // We want to stop using the asset cache thread asap // as we now need to do the work of producing the rest of the archive - Util.FireAndForget(PerformAssetsRequestCallback); + Util.FireAndForget(PerformAssetsRequestCallback, false); } else { @@ -315,9 +315,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver { Culture.SetCurrentCulture(); + Boolean timedOut = (Boolean)o; + try { - m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids); + m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids, timedOut); } catch (Exception e) { -- cgit v1.1