diff options
author | Sean McNamara | 2011-04-26 11:42:06 -0400 |
---|---|---|
committer | Sean McNamara | 2011-04-26 11:42:06 -0400 |
commit | c82c7e6ed9ecf4858d5afffa635013bd14e90bdf (patch) | |
tree | 0cfc6b76daefda6deaf9239065ae5396124d8faa /OpenSim/Region | |
parent | Merge git://opensimulator.org/git/opensim (diff) | |
download | opensim-SC-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.zip opensim-SC-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.tar.gz opensim-SC-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.tar.bz2 opensim-SC-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.tar.xz |
Wait for OnOarFileSaved event callback before executing script
We want to execute the (optional) user script after I/O is done on the oar.
I wasn't aware that ArchiveRegion is asynchronous -- now I am.
Should fully resolve comment 0018290 at
http://opensimulator.org/mantis/view.php?id=5440
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs | 14 |
2 files changed, 29 insertions, 8 deletions
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index 7c0a5c6..bd4893c 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs | |||
@@ -94,18 +94,14 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
94 | private static readonly ILog m_log = | 94 | private static readonly ILog m_log = |
95 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 95 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
96 | 96 | ||
97 | /// True means IRegionModuleBase.Close() was called on us, and we should stop operation ASAP. | ||
98 | /// Used to prevent elapsing timers after Close() is called from trying to start an autobackup while the sim is shutting down. | ||
99 | private readonly AutoBackupModuleState m_defaultState = new AutoBackupModuleState(); | ||
100 | |||
101 | /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions. | 97 | /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions. |
102 | /// Also helps if you don't want AutoBackup at all | 98 | /// Also helps if you don't want AutoBackup at all |
99 | private readonly Dictionary<Guid, IScene> m_pendingSaves = new Dictionary<Guid, IScene>(1); | ||
100 | private readonly AutoBackupModuleState m_defaultState = new AutoBackupModuleState(); | ||
103 | private readonly Dictionary<IScene, AutoBackupModuleState> m_states = | 101 | private readonly Dictionary<IScene, AutoBackupModuleState> m_states = |
104 | new Dictionary<IScene, AutoBackupModuleState>(1); | 102 | new Dictionary<IScene, AutoBackupModuleState>(1); |
105 | |||
106 | private readonly Dictionary<Timer, List<IScene>> m_timerMap = | 103 | private readonly Dictionary<Timer, List<IScene>> m_timerMap = |
107 | new Dictionary<Timer, List<IScene>>(1); | 104 | new Dictionary<Timer, List<IScene>>(1); |
108 | |||
109 | private readonly Dictionary<double, Timer> m_timers = new Dictionary<double, Timer>(1); | 105 | private readonly Dictionary<double, Timer> m_timers = new Dictionary<double, Timer>(1); |
110 | 106 | ||
111 | private bool m_enabled; | 107 | private bool m_enabled; |
@@ -528,8 +524,19 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
528 | m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed"); | 524 | m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed"); |
529 | return; | 525 | return; |
530 | } | 526 | } |
531 | iram.ArchiveRegion(savePath, Guid.NewGuid(), null); | 527 | Guid guid = Guid.NewGuid(); |
532 | ExecuteScript(state.Script, savePath); | 528 | m_pendingSaves.Add(guid, scene); |
529 | state.LiveRequests.Add(guid, savePath); | ||
530 | ((Scene) scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved); | ||
531 | iram.ArchiveRegion(savePath, guid, null); | ||
532 | } | ||
533 | |||
534 | void EventManager_OnOarFileSaved(Guid guid, string message) | ||
535 | { | ||
536 | AutoBackupModuleState abms = m_states[(m_pendingSaves[guid])]; | ||
537 | ExecuteScript(abms.Script, abms.LiveRequests[guid]); | ||
538 | m_pendingSaves.Remove(guid); | ||
539 | abms.LiveRequests.Remove(guid); | ||
533 | } | 540 | } |
534 | 541 | ||
535 | /// This format may turn out to be too unwieldy to keep... | 542 | /// This format may turn out to be too unwieldy to keep... |
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs index 1b348af..7fecfa4 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs | |||
@@ -26,11 +26,17 @@ | |||
26 | /// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 | /// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | /// | 27 | /// |
28 | 28 | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | |||
32 | |||
29 | namespace OpenSim.Region.OptionalModules.World.AutoBackup | 33 | namespace OpenSim.Region.OptionalModules.World.AutoBackup |
30 | { | 34 | { |
31 | /// AutoBackupModuleState: Auto-Backup state for one region (scene). | 35 | /// AutoBackupModuleState: Auto-Backup state for one region (scene). |
32 | public class AutoBackupModuleState | 36 | public class AutoBackupModuleState |
33 | { | 37 | { |
38 | private Dictionary<Guid, string> m_liveRequests = null; | ||
39 | |||
34 | public AutoBackupModuleState() | 40 | public AutoBackupModuleState() |
35 | { | 41 | { |
36 | this.Enabled = false; | 42 | this.Enabled = false; |
@@ -41,6 +47,14 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
41 | this.Script = null; | 47 | this.Script = null; |
42 | } | 48 | } |
43 | 49 | ||
50 | public Dictionary<Guid, string> LiveRequests | ||
51 | { | ||
52 | get { | ||
53 | return this.m_liveRequests ?? | ||
54 | (this.m_liveRequests = new Dictionary<Guid, string>(1)); | ||
55 | } | ||
56 | } | ||
57 | |||
44 | public bool Enabled | 58 | public bool Enabled |
45 | { | 59 | { |
46 | get; | 60 | get; |