aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs34
1 files changed, 24 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 828f2fb..1dd50c7 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -107,6 +107,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine
107 private IXmlRpcRouter m_XmlRpcRouter; 107 private IXmlRpcRouter m_XmlRpcRouter;
108 private int m_EventLimit; 108 private int m_EventLimit;
109 private bool m_KillTimedOutScripts; 109 private bool m_KillTimedOutScripts;
110
111 /// <summary>
112 /// Number of milliseconds we will wait for a script event to complete on script stop before we forcibly abort
113 /// its thread.
114 /// </summary>
115 /// <remarks>
116 /// It appears that if a script thread is aborted whilst it is holding ReaderWriterLockSlim (possibly the write
117 /// lock) then the lock is not properly released. This causes mono 2.6, 2.10 and possibly
118 /// later to crash, sometimes with symptoms such as a leap to 100% script usage and a vm thead dump showing
119 /// all threads waiting on release of ReaderWriterLockSlim write thread which none of the threads listed
120 /// actually hold.
121 ///
122 /// Pausing for event completion reduces the risk of this happening. However, it may be that aborting threads
123 /// is not a mono issue per se but rather a risky activity in itself in an AppDomain that is not immediately
124 /// shutting down.
125 /// </remarks>
126 private int m_WaitForEventCompletionOnScriptStop = 1000;
127
110 private string m_ScriptEnginesPath = null; 128 private string m_ScriptEnginesPath = null;
111 129
112 private ExpiringCache<UUID, bool> m_runFlags = new ExpiringCache<UUID, bool>(); 130 private ExpiringCache<UUID, bool> m_runFlags = new ExpiringCache<UUID, bool>();
@@ -249,6 +267,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
249 m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); 267 m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30);
250 m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); 268 m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false);
251 m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000; 269 m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000;
270 m_WaitForEventCompletionOnScriptStop
271 = m_ScriptConfig.GetInt("WaitForEventCompletionOnScriptStop", m_WaitForEventCompletionOnScriptStop);
272
252 m_ScriptEnginesPath = m_ScriptConfig.GetString("ScriptEnginesPath", "ScriptEngines"); 273 m_ScriptEnginesPath = m_ScriptConfig.GetString("ScriptEnginesPath", "ScriptEngines");
253 274
254 m_Prio = ThreadPriority.BelowNormal; 275 m_Prio = ThreadPriority.BelowNormal;
@@ -1335,9 +1356,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1335 1356
1336 instance.ClearQueue(); 1357 instance.ClearQueue();
1337 1358
1338 // Give the script some time to finish processing its last event. Simply aborting the script thread can 1359 instance.Stop(m_WaitForEventCompletionOnScriptStop);
1339 // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort.
1340 instance.Stop(1000);
1341 1360
1342// bool objectRemoved = false; 1361// bool objectRemoved = false;
1343 1362
@@ -1687,16 +1706,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1687 public void StopScript(UUID itemID) 1706 public void StopScript(UUID itemID)
1688 { 1707 {
1689 IScriptInstance instance = GetInstance(itemID); 1708 IScriptInstance instance = GetInstance(itemID);
1709
1690 if (instance != null) 1710 if (instance != null)
1691 { 1711 instance.Stop(m_WaitForEventCompletionOnScriptStop);
1692 // Give the script some time to finish processing its last event. Simply aborting the script thread can
1693 // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort.
1694 instance.Stop(1000);
1695 }
1696 else 1712 else
1697 {
1698 m_runFlags.AddOrUpdate(itemID, false, 240); 1713 m_runFlags.AddOrUpdate(itemID, false, 240);
1699 }
1700 } 1714 }
1701 1715
1702 public DetectParams GetDetectParams(UUID itemID, int idx) 1716 public DetectParams GetDetectParams(UUID itemID, int idx)