change Backup calls overlap control code

0.9.0-post-fixes
UbitUmarov 2017-06-25 15:42:36 +01:00
parent 84abdf866a
commit 3ce909528d
1 changed files with 45 additions and 26 deletions

View File

@ -1942,7 +1942,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (!m_backingup) if (!m_backingup)
{ {
m_backingup = true;
WorkManager.RunInThreadPool(o => Backup(false), null, string.Format("BackupWorker ({0})", Name)); WorkManager.RunInThreadPool(o => Backup(false), null, string.Format("BackupWorker ({0})", Name));
} }
} }
@ -1971,38 +1970,58 @@ namespace OpenSim.Region.Framework.Scenes
{ {
lock (m_returns) lock (m_returns)
{ {
EventManager.TriggerOnBackup(SimulationDataService, forced); if(m_backingup)
foreach (KeyValuePair<UUID, ReturnInfo> ret in m_returns)
{ {
UUID transaction = UUID.Random(); m_log.WarnFormat("[Scene] Backup of {0} already running. New call skipped", RegionInfo.RegionName);
return;
}
GridInstantMessage msg = new GridInstantMessage(); m_backingup = true;
msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server try
msg.toAgentID = new Guid(ret.Key.ToString()); {
msg.imSessionID = new Guid(transaction.ToString()); EventManager.TriggerOnBackup(SimulationDataService, forced);
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
msg.fromAgentName = "Server";
msg.dialog = (byte)19; // Object msg
msg.fromGroup = false;
msg.offline = (byte)1;
msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
msg.Position = Vector3.Zero;
msg.RegionID = RegionInfo.RegionID.Guid;
// We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3. if(m_returns.Count == 0)
msg.binaryBucket = Util.StringToBytes256("\0"); return;
if (ret.Value.count > 1)
msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
else
msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>(); IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>();
if (tr != null) if (tr == null)
return;
uint unixtime = (uint)Util.UnixTimeSinceEpoch();
uint estateid = RegionInfo.EstateSettings.ParentEstateID;
Guid regionguid = RegionInfo.RegionID.Guid;
foreach (KeyValuePair<UUID, ReturnInfo> ret in m_returns)
{
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = Guid.Empty; // From server
msg.toAgentID = ret.Key.Guid;
msg.imSessionID = Guid.NewGuid();
msg.timestamp = unixtime;
msg.fromAgentName = "Server";
msg.dialog = 19; // Object msg
msg.fromGroup = false;
msg.offline = 1;
msg.ParentEstateID = estateid;
msg.Position = Vector3.Zero;
msg.RegionID = regionguid;
// We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3.
msg.binaryBucket = new Byte[1] {0};
if (ret.Value.count > 1)
msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
else
msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
tr.SendInstantMessage(msg, delegate(bool success) { }); tr.SendInstantMessage(msg, delegate(bool success) { });
}
m_returns.Clear();
}
finally
{
m_backingup = false;
} }
m_returns.Clear();
m_backingup = false;
} }
} }