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/OptionalModules/World/AutoBackup/AutoBackupModule.cs | |
parent | Merge git://opensimulator.org/git/opensim (diff) | |
download | opensim-SC_OLD-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.zip opensim-SC_OLD-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.tar.gz opensim-SC_OLD-c82c7e6ed9ecf4858d5afffa635013bd14e90bdf.tar.bz2 opensim-SC_OLD-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 '')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs | 23 |
1 files changed, 15 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... |