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; 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; Exception reportedException = null;
bool succeeded = true; bool succeeded = true;
@ -143,6 +143,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_saveStream.Close(); m_saveStream.Close();
} }
if (timedOut)
{
succeeded = false;
reportedException = new Exception("Loading assets timed out");
}
m_module.TriggerInventoryArchiveSaved( m_module.TriggerInventoryArchiveSaved(
m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); 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"); 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) catch (Exception)

View File

@ -587,19 +587,29 @@ namespace OpenSim.Region.CoreModules.World.Archiver
} }
} }
protected void ReceivedAllAssets( protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut)
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
{ {
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);
errorMessage = String.Empty;
} }
// m_log.InfoFormat( CloseArchive(errorMessage);
// "[ARCHIVER]: Received {0} of {1} assets requested",
// assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);
CloseArchive(String.Empty);
} }
/// <summary> /// <summary>

View File

@ -150,12 +150,5 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_log.InfoFormat("[ARCHIVER]: Added {0} assets to archive", m_assetsWritten); 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. /// Method called when all the necessary assets for an archive request have been received.
/// </summary> /// </summary>
public delegate void AssetsRequestCallback( public delegate void AssetsRequestCallback(
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids); ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut);
enum RequestState enum RequestState
{ {
@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if (m_repliesRequired == 0) if (m_repliesRequired == 0)
{ {
m_requestState = RequestState.Completed; m_requestState = RequestState.Completed;
PerformAssetsRequestCallback(null); PerformAssetsRequestCallback(false);
return; return;
} }
@ -164,7 +164,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args) protected void OnRequestCallbackTimeout(object source, ElapsedEventArgs args)
{ {
bool close = true; bool timedOut = true;
try try
{ {
@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// the final request came in (assuming that such a thing is possible) // the final request came in (assuming that such a thing is possible)
if (m_requestState == RequestState.Completed) if (m_requestState == RequestState.Completed)
{ {
close = false; timedOut = false;
return; return;
} }
@ -223,8 +223,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
} }
finally finally
{ {
if (close) if (timedOut)
m_assetsArchiver.ForceClose(); Util.FireAndForget(PerformAssetsRequestCallback, true);
} }
} }
@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// We want to stop using the asset cache thread asap // 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 // as we now need to do the work of producing the rest of the archive
Util.FireAndForget(PerformAssetsRequestCallback); Util.FireAndForget(PerformAssetsRequestCallback, false);
} }
else else
{ {
@ -315,9 +315,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{ {
Culture.SetCurrentCulture(); Culture.SetCurrentCulture();
Boolean timedOut = (Boolean)o;
try try
{ {
m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids); m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids, timedOut);
} }
catch (Exception e) catch (Exception e)
{ {