From 3ce909528dd42cd2c92d8ac6590135bb1962aee4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 25 Jun 2017 15:42:36 +0100 Subject: change Backup calls overlap control code --- OpenSim/Region/Framework/Scenes/Scene.cs | 73 ++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ebef158..09b209e 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1942,7 +1942,6 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_backingup) { - m_backingup = true; WorkManager.RunInThreadPool(o => Backup(false), null, string.Format("BackupWorker ({0})", Name)); } } @@ -1971,38 +1970,58 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_returns) { - EventManager.TriggerOnBackup(SimulationDataService, forced); + if(m_backingup) + { + m_log.WarnFormat("[Scene] Backup of {0} already running. New call skipped", RegionInfo.RegionName); + return; + } - foreach (KeyValuePair ret in m_returns) + m_backingup = true; + try { - UUID transaction = UUID.Random(); - - GridInstantMessage msg = new GridInstantMessage(); - msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server - msg.toAgentID = new Guid(ret.Key.ToString()); - msg.imSessionID = new Guid(transaction.ToString()); - 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. - msg.binaryBucket = Util.StringToBytes256("\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); + EventManager.TriggerOnBackup(SimulationDataService, forced); + + if(m_returns.Count == 0) + return; IMessageTransferModule tr = RequestModuleInterface(); - if (tr != null) + if (tr == null) + return; + + uint unixtime = (uint)Util.UnixTimeSinceEpoch(); + uint estateid = RegionInfo.EstateSettings.ParentEstateID; + Guid regionguid = RegionInfo.RegionID.Guid; + + foreach (KeyValuePair 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) { }); + } + m_returns.Clear(); + } + finally + { + m_backingup = false; } - m_returns.Clear(); - m_backingup = false; } } -- cgit v1.1