If Save OAR/IAR times-out while waiting for assets then notify the caller that the operation failed

user_profiles
Oren Hurvitz 2012-08-23 21:23:16 +03:00 committed by Justin Clark-Casey (justincc)
parent 6b55f51837
commit d2f4ca0dfe
4 changed files with 37 additions and 26 deletions

View File

@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
SaveAssets = true;
}
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> 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<UUID>(), new List<UUID>());
ReceivedAllAssets(new List<UUID>(), new List<UUID>(), false);
}
}
catch (Exception)

View File

@ -587,19 +587,29 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
}
protected void ReceivedAllAssets(
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> 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);
}
/// <summary>
@ -626,4 +636,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage);
}
}
}
}

View File

@ -150,12 +150,5 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_log.InfoFormat("[ARCHIVER]: Added {0} assets to archive", m_assetsWritten);
}
/// <summary>
/// Only call this if you need to force a close on the underlying writer.
/// </summary>
public void ForceClose()
{
m_archiveWriter.Close();
}
}
}

View File

@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// Method called when all the necessary assets for an archive request have been received.
/// </summary>
public delegate void AssetsRequestCallback(
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids);
ICollection<UUID> assetsFoundUuids, ICollection<UUID> 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)
{