diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 5ff56a1..d28b151 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -1022,9 +1022,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1022 | 1022 | ||
1023 | public void SaveState() | 1023 | public void SaveState() |
1024 | { | 1024 | { |
1025 | if (!Running) | ||
1026 | return; | ||
1027 | |||
1028 | // We cannot call this inside the EventQueue lock since it will currently take AsyncCommandManager.staticLock. | ||
1029 | // This may already be held by AsyncCommandManager.DoOneCmdHandlerPass() which in turn can take EventQueue | ||
1030 | // lock via ScriptInstance.PostEvent(). | ||
1031 | PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); | ||
1032 | |||
1025 | // We need to lock here to avoid any race with a thread that is removing this script. | 1033 | // We need to lock here to avoid any race with a thread that is removing this script. |
1026 | lock (EventQueue) | 1034 | lock (EventQueue) |
1027 | { | 1035 | { |
1036 | // Check again to avoid a race with a thread in Stop() | ||
1028 | if (!Running) | 1037 | if (!Running) |
1029 | return; | 1038 | return; |
1030 | 1039 | ||
@@ -1040,8 +1049,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1040 | // "[SCRIPT INSTANCE]: Saving state for script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}", | 1049 | // "[SCRIPT INSTANCE]: Saving state for script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}", |
1041 | // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name); | 1050 | // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name); |
1042 | 1051 | ||
1043 | PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); | ||
1044 | |||
1045 | string xml = ScriptSerializer.Serialize(this); | 1052 | string xml = ScriptSerializer.Serialize(this); |
1046 | 1053 | ||
1047 | // Compare hash of the state we just just created with the state last written to disk | 1054 | // Compare hash of the state we just just created with the state last written to disk |