diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 341 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 23 |
4 files changed, 158 insertions, 225 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9e59d50..3a066d4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -219,8 +219,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
219 | 219 | ||
220 | private int m_lastUpdate; | 220 | private int m_lastUpdate; |
221 | private bool m_firstHeartbeat = true; | 221 | private bool m_firstHeartbeat = true; |
222 | |||
223 | private object m_deleting_scene_object = new object(); | ||
224 | 222 | ||
225 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 223 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
226 | private bool m_reprioritizationEnabled = true; | 224 | private bool m_reprioritizationEnabled = true; |
@@ -1994,15 +1992,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1994 | public void DeleteSceneObject(SceneObjectGroup group, bool silent) | 1992 | public void DeleteSceneObject(SceneObjectGroup group, bool silent) |
1995 | { | 1993 | { |
1996 | // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); | 1994 | // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); |
1997 | |||
1998 | //SceneObjectPart rootPart = group.GetChildPart(group.UUID); | ||
1999 | 1995 | ||
2000 | // Serialise calls to RemoveScriptInstances to avoid | 1996 | group.RemoveScriptInstances(true); |
2001 | // deadlocking on m_parts inside SceneObjectGroup | ||
2002 | lock (m_deleting_scene_object) | ||
2003 | { | ||
2004 | group.RemoveScriptInstances(true); | ||
2005 | } | ||
2006 | 1997 | ||
2007 | SceneObjectPart[] partList = group.Parts; | 1998 | SceneObjectPart[] partList = group.Parts; |
2008 | 1999 | ||
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index f00e41f..8762642 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -68,8 +68,16 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
68 | /// </summary> | 68 | /// </summary> |
69 | bool Suspended { get; set; } | 69 | bool Suspended { get; set; } |
70 | 70 | ||
71 | /// <summary> | ||
72 | /// Is the script shutting down? | ||
73 | /// </summary> | ||
71 | bool ShuttingDown { get; set; } | 74 | bool ShuttingDown { get; set; } |
75 | |||
76 | /// <summary> | ||
77 | /// Script state | ||
78 | /// </summary> | ||
72 | string State { get; set; } | 79 | string State { get; set; } |
80 | |||
73 | IScriptEngine Engine { get; } | 81 | IScriptEngine Engine { get; } |
74 | UUID AppDomain { get; set; } | 82 | UUID AppDomain { get; set; } |
75 | string PrimName { get; } | 83 | string PrimName { get; } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index b840730..968351b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -56,44 +56,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
56 | public class ScriptInstance : MarshalByRefObject, IScriptInstance | 56 | public class ScriptInstance : MarshalByRefObject, IScriptInstance |
57 | { | 57 | { |
58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
59 | |||
60 | private IScriptEngine m_Engine; | ||
61 | 59 | ||
62 | /// <summary> | 60 | /// <summary> |
63 | /// The current work item if an event for this script is running or waiting to run, | 61 | /// The current work item if an event for this script is running or waiting to run, |
64 | /// </summary> | 62 | /// </summary> |
65 | /// <remarks> | 63 | /// <remarks> |
66 | /// Null if there is no running or waiting to run event. Must be changed only under an m_EventQueue lock. | 64 | /// Null if there is no running or waiting to run event. Must be changed only under an EventQueue lock. |
67 | /// </remarks> | 65 | /// </remarks> |
68 | private IScriptWorkItem m_CurrentWorkItem; | 66 | private IScriptWorkItem m_CurrentWorkItem; |
69 | 67 | ||
70 | private Queue m_EventQueue = new Queue(32); | ||
71 | private bool m_RunEvents = false; | ||
72 | private UUID m_ItemID; | ||
73 | private uint m_LocalID; | ||
74 | private UUID m_ObjectID; | ||
75 | private UUID m_AssetID; | ||
76 | private IScript m_Script; | 68 | private IScript m_Script; |
77 | private UUID m_AppDomain; | ||
78 | private DetectParams[] m_DetectParams; | 69 | private DetectParams[] m_DetectParams; |
79 | private bool m_TimerQueued; | 70 | private bool m_TimerQueued; |
80 | private DateTime m_EventStart; | 71 | private DateTime m_EventStart; |
81 | private bool m_InEvent; | 72 | private bool m_InEvent; |
82 | private string m_PrimName; | ||
83 | private string m_ScriptName; | ||
84 | private string m_Assembly; | 73 | private string m_Assembly; |
85 | private int m_StartParam; | ||
86 | private string m_CurrentEvent = String.Empty; | 74 | private string m_CurrentEvent = String.Empty; |
87 | private bool m_InSelfDelete; | 75 | private bool m_InSelfDelete; |
88 | private int m_MaxScriptQueue; | 76 | private int m_MaxScriptQueue; |
89 | private bool m_SaveState = true; | 77 | private bool m_SaveState = true; |
90 | private bool m_ShuttingDown; | ||
91 | private int m_ControlEventsInQueue; | 78 | private int m_ControlEventsInQueue; |
92 | private int m_LastControlLevel; | 79 | private int m_LastControlLevel; |
93 | private bool m_CollisionInQueue; | 80 | private bool m_CollisionInQueue; |
94 | private TaskInventoryItem m_thisScriptTask; | 81 | |
95 | // The following is for setting a minimum delay between events | 82 | // The following is for setting a minimum delay between events |
96 | private double m_minEventDelay; | 83 | private double m_minEventDelay; |
84 | |||
97 | private long m_eventDelayTicks; | 85 | private long m_eventDelayTicks; |
98 | private long m_nextEventTimeTicks; | 86 | private long m_nextEventTimeTicks; |
99 | private bool m_startOnInit = true; | 87 | private bool m_startOnInit = true; |
@@ -104,21 +92,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
104 | private UUID m_CurrentStateHash; | 92 | private UUID m_CurrentStateHash; |
105 | private UUID m_RegionID; | 93 | private UUID m_RegionID; |
106 | 94 | ||
107 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 95 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; } |
108 | m_LineMap; | ||
109 | |||
110 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | ||
111 | LineMap | ||
112 | { | ||
113 | get { return m_LineMap; } | ||
114 | set { m_LineMap = value; } | ||
115 | } | ||
116 | 96 | ||
117 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); | 97 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); |
118 | 98 | ||
119 | // Script state | ||
120 | private string m_State = "default"; | ||
121 | |||
122 | public Object[] PluginData = new Object[0]; | 99 | public Object[] PluginData = new Object[0]; |
123 | 100 | ||
124 | /// <summary> | 101 | /// <summary> |
@@ -141,11 +118,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
141 | } | 118 | } |
142 | } | 119 | } |
143 | 120 | ||
144 | public bool Running | 121 | public bool Running { get; set; } |
145 | { | ||
146 | get { return m_RunEvents; } | ||
147 | set { m_RunEvents = value; } | ||
148 | } | ||
149 | 122 | ||
150 | public bool Suspended | 123 | public bool Suspended |
151 | { | 124 | { |
@@ -161,11 +134,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
161 | 134 | ||
162 | if (wasSuspended && !m_Suspended) | 135 | if (wasSuspended && !m_Suspended) |
163 | { | 136 | { |
164 | lock (m_EventQueue) | 137 | lock (EventQueue) |
165 | { | 138 | { |
166 | // Need to place ourselves back in a work item if there are events to process | 139 | // Need to place ourselves back in a work item if there are events to process |
167 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 140 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
168 | m_CurrentWorkItem = m_Engine.QueueEventHandler(this); | 141 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
169 | } | 142 | } |
170 | } | 143 | } |
171 | } | 144 | } |
@@ -173,79 +146,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
173 | } | 146 | } |
174 | private bool m_Suspended; | 147 | private bool m_Suspended; |
175 | 148 | ||
176 | public bool ShuttingDown | 149 | public bool ShuttingDown { get; set; } |
177 | { | ||
178 | get { return m_ShuttingDown; } | ||
179 | set { m_ShuttingDown = value; } | ||
180 | } | ||
181 | 150 | ||
182 | public string State | 151 | public string State { get; set; } |
183 | { | ||
184 | get { return m_State; } | ||
185 | set { m_State = value; } | ||
186 | } | ||
187 | 152 | ||
188 | public IScriptEngine Engine | 153 | public IScriptEngine Engine { get; private set; } |
189 | { | ||
190 | get { return m_Engine; } | ||
191 | } | ||
192 | 154 | ||
193 | public UUID AppDomain | 155 | public UUID AppDomain { get; set; } |
194 | { | ||
195 | get { return m_AppDomain; } | ||
196 | set { m_AppDomain = value; } | ||
197 | } | ||
198 | 156 | ||
199 | public string PrimName | 157 | public string PrimName { get; private set; } |
200 | { | ||
201 | get { return m_PrimName; } | ||
202 | } | ||
203 | 158 | ||
204 | public string ScriptName | 159 | public string ScriptName { get; private set; } |
205 | { | ||
206 | get { return m_ScriptName; } | ||
207 | } | ||
208 | 160 | ||
209 | public UUID ItemID | 161 | public UUID ItemID { get; private set; } |
210 | { | ||
211 | get { return m_ItemID; } | ||
212 | } | ||
213 | 162 | ||
214 | public UUID ObjectID | 163 | public UUID ObjectID { get; private set; } |
215 | { | ||
216 | get { return m_ObjectID; } | ||
217 | } | ||
218 | 164 | ||
219 | public uint LocalID | 165 | public uint LocalID { get; private set; } |
220 | { | ||
221 | get { return m_LocalID; } | ||
222 | } | ||
223 | 166 | ||
224 | public UUID AssetID | 167 | public UUID AssetID { get; private set; } |
225 | { | ||
226 | get { return m_AssetID; } | ||
227 | } | ||
228 | 168 | ||
229 | public Queue EventQueue | 169 | public Queue EventQueue { get; private set; } |
230 | { | ||
231 | get { return m_EventQueue; } | ||
232 | } | ||
233 | 170 | ||
234 | public void ClearQueue() | 171 | public int StartParam { get; set; } |
235 | { | ||
236 | m_TimerQueued = false; | ||
237 | m_EventQueue.Clear(); | ||
238 | } | ||
239 | 172 | ||
240 | public int StartParam | 173 | public TaskInventoryItem ScriptTask { get; private set; } |
241 | { | ||
242 | get { return m_StartParam; } | ||
243 | set { m_StartParam = value; } | ||
244 | } | ||
245 | 174 | ||
246 | public TaskInventoryItem ScriptTask | 175 | public void ClearQueue() |
247 | { | 176 | { |
248 | get { return m_thisScriptTask; } | 177 | m_TimerQueued = false; |
178 | EventQueue.Clear(); | ||
249 | } | 179 | } |
250 | 180 | ||
251 | public ScriptInstance(IScriptEngine engine, SceneObjectPart part, | 181 | public ScriptInstance(IScriptEngine engine, SceneObjectPart part, |
@@ -254,16 +184,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
254 | int startParam, bool postOnRez, StateSource stateSource, | 184 | int startParam, bool postOnRez, StateSource stateSource, |
255 | int maxScriptQueue) | 185 | int maxScriptQueue) |
256 | { | 186 | { |
257 | m_Engine = engine; | 187 | State = "default"; |
258 | 188 | EventQueue = new Queue(32); | |
259 | m_LocalID = part.LocalId; | 189 | |
260 | m_ObjectID = part.UUID; | 190 | Engine = engine; |
261 | m_ItemID = itemID; | 191 | LocalID = part.LocalId; |
262 | m_AssetID = assetID; | 192 | ObjectID = part.UUID; |
263 | m_PrimName = primName; | 193 | ItemID = itemID; |
264 | m_ScriptName = scriptName; | 194 | AssetID = assetID; |
195 | PrimName = primName; | ||
196 | ScriptName = scriptName; | ||
265 | m_Assembly = assembly; | 197 | m_Assembly = assembly; |
266 | m_StartParam = startParam; | 198 | StartParam = startParam; |
267 | m_MaxScriptQueue = maxScriptQueue; | 199 | m_MaxScriptQueue = maxScriptQueue; |
268 | m_stateSource = stateSource; | 200 | m_stateSource = stateSource; |
269 | m_postOnRez = postOnRez; | 201 | m_postOnRez = postOnRez; |
@@ -274,9 +206,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
274 | { | 206 | { |
275 | lock (part.TaskInventory) | 207 | lock (part.TaskInventory) |
276 | { | 208 | { |
277 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 209 | if (part.TaskInventory.ContainsKey(ItemID)) |
278 | { | 210 | { |
279 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | 211 | ScriptTask = part.TaskInventory[ItemID]; |
280 | } | 212 | } |
281 | } | 213 | } |
282 | } | 214 | } |
@@ -286,20 +218,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
286 | foreach (string api in am.GetApis()) | 218 | foreach (string api in am.GetApis()) |
287 | { | 219 | { |
288 | m_Apis[api] = am.CreateApi(api); | 220 | m_Apis[api] = am.CreateApi(api); |
289 | m_Apis[api].Initialize(engine, part, m_LocalID, itemID); | 221 | m_Apis[api].Initialize(engine, part, LocalID, itemID); |
290 | } | 222 | } |
291 | 223 | ||
292 | try | 224 | try |
293 | { | 225 | { |
294 | if (dom != System.AppDomain.CurrentDomain) | 226 | if (dom != System.AppDomain.CurrentDomain) |
295 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( | 227 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( |
296 | Path.GetFileNameWithoutExtension(assembly), | 228 | Path.GetFileNameWithoutExtension(assembly), |
297 | "SecondLife.Script"); | 229 | "SecondLife.Script"); |
298 | else | 230 | else |
299 | m_Script = (IScript)Assembly.Load( | 231 | m_Script = (IScript)Assembly.Load( |
300 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( | 232 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( |
301 | "SecondLife.Script"); | 233 | "SecondLife.Script"); |
302 | |||
303 | 234 | ||
304 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 235 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
305 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 236 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
@@ -321,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
321 | 252 | ||
322 | // // m_log.Debug("[Script] Script instance created"); | 253 | // // m_log.Debug("[Script] Script instance created"); |
323 | 254 | ||
324 | part.SetScriptEvents(m_ItemID, | 255 | part.SetScriptEvents(ItemID, |
325 | (int)m_Script.GetStateEventFlags(State)); | 256 | (int)m_Script.GetStateEventFlags(State)); |
326 | } | 257 | } |
327 | catch (Exception e) | 258 | catch (Exception e) |
@@ -336,7 +267,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
336 | m_SaveState = true; | 267 | m_SaveState = true; |
337 | 268 | ||
338 | string savedState = Path.Combine(Path.GetDirectoryName(assembly), | 269 | string savedState = Path.Combine(Path.GetDirectoryName(assembly), |
339 | m_ItemID.ToString() + ".state"); | 270 | ItemID.ToString() + ".state"); |
340 | if (File.Exists(savedState)) | 271 | if (File.Exists(savedState)) |
341 | { | 272 | { |
342 | string xml = String.Empty; | 273 | string xml = String.Empty; |
@@ -360,24 +291,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
360 | 291 | ||
361 | ScriptSerializer.Deserialize(xml, this); | 292 | ScriptSerializer.Deserialize(xml, this); |
362 | 293 | ||
363 | AsyncCommandManager.CreateFromData(m_Engine, | 294 | AsyncCommandManager.CreateFromData(Engine, |
364 | m_LocalID, m_ItemID, m_ObjectID, | 295 | LocalID, ItemID, ObjectID, |
365 | PluginData); | 296 | PluginData); |
366 | 297 | ||
367 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName); | 298 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); |
368 | 299 | ||
369 | part.SetScriptEvents(m_ItemID, | 300 | part.SetScriptEvents(ItemID, |
370 | (int)m_Script.GetStateEventFlags(State)); | 301 | (int)m_Script.GetStateEventFlags(State)); |
371 | 302 | ||
372 | if (m_RunEvents && (!m_ShuttingDown)) | 303 | Running = false; |
373 | { | 304 | |
374 | m_RunEvents = false; | 305 | if (ShuttingDown) |
375 | } | ||
376 | else | ||
377 | { | ||
378 | m_RunEvents = false; | ||
379 | m_startOnInit = false; | 306 | m_startOnInit = false; |
380 | } | ||
381 | 307 | ||
382 | // we get new rez events on sim restart, too | 308 | // we get new rez events on sim restart, too |
383 | // but if there is state, then we fire the change | 309 | // but if there is state, then we fire the change |
@@ -386,7 +312,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
386 | // We loaded state, don't force a re-save | 312 | // We loaded state, don't force a re-save |
387 | m_SaveState = false; | 313 | m_SaveState = false; |
388 | m_startedFromSavedState = true; | 314 | m_startedFromSavedState = true; |
389 | |||
390 | } | 315 | } |
391 | } | 316 | } |
392 | else | 317 | else |
@@ -405,7 +330,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
405 | } | 330 | } |
406 | // else | 331 | // else |
407 | // { | 332 | // { |
408 | // ScenePresence presence = m_Engine.World.GetScenePresence(part.OwnerID); | 333 | // ScenePresence presence = Engine.World.GetScenePresence(part.OwnerID); |
409 | 334 | ||
410 | // if (presence != null && (!postOnRez)) | 335 | // if (presence != null && (!postOnRez)) |
411 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); | 336 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); |
@@ -423,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
423 | if (m_postOnRez) | 348 | if (m_postOnRez) |
424 | { | 349 | { |
425 | PostEvent(new EventParams("on_rez", | 350 | PostEvent(new EventParams("on_rez", |
426 | new Object[] {new LSL_Types.LSLInteger(m_StartParam)}, new DetectParams[0])); | 351 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); |
427 | } | 352 | } |
428 | 353 | ||
429 | if (m_stateSource == StateSource.AttachedRez) | 354 | if (m_stateSource == StateSource.AttachedRez) |
@@ -457,7 +382,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
457 | if (m_postOnRez) | 382 | if (m_postOnRez) |
458 | { | 383 | { |
459 | PostEvent(new EventParams("on_rez", | 384 | PostEvent(new EventParams("on_rez", |
460 | new Object[] {new LSL_Types.LSLInteger(m_StartParam)}, new DetectParams[0])); | 385 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); |
461 | } | 386 | } |
462 | 387 | ||
463 | if (m_stateSource == StateSource.AttachedRez) | 388 | if (m_stateSource == StateSource.AttachedRez) |
@@ -471,7 +396,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
471 | 396 | ||
472 | private void ReleaseControls() | 397 | private void ReleaseControls() |
473 | { | 398 | { |
474 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart(m_LocalID); | 399 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
475 | 400 | ||
476 | if (part != null) | 401 | if (part != null) |
477 | { | 402 | { |
@@ -479,18 +404,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
479 | UUID permsGranter; | 404 | UUID permsGranter; |
480 | lock (part.TaskInventory) | 405 | lock (part.TaskInventory) |
481 | { | 406 | { |
482 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 407 | if (!part.TaskInventory.ContainsKey(ItemID)) |
483 | return; | 408 | return; |
484 | 409 | ||
485 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | 410 | permsGranter = part.TaskInventory[ItemID].PermsGranter; |
486 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | 411 | permsMask = part.TaskInventory[ItemID].PermsMask; |
487 | } | 412 | } |
488 | 413 | ||
489 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 414 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
490 | { | 415 | { |
491 | ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter); | 416 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); |
492 | if (presence != null) | 417 | if (presence != null) |
493 | presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); | 418 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); |
494 | } | 419 | } |
495 | } | 420 | } |
496 | } | 421 | } |
@@ -498,13 +423,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
498 | public void DestroyScriptInstance() | 423 | public void DestroyScriptInstance() |
499 | { | 424 | { |
500 | ReleaseControls(); | 425 | ReleaseControls(); |
501 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 426 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
502 | } | 427 | } |
503 | 428 | ||
504 | public void RemoveState() | 429 | public void RemoveState() |
505 | { | 430 | { |
506 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), | 431 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), |
507 | m_ItemID.ToString() + ".state"); | 432 | ItemID.ToString() + ".state"); |
508 | 433 | ||
509 | try | 434 | try |
510 | { | 435 | { |
@@ -517,7 +442,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
517 | 442 | ||
518 | public void VarDump(Dictionary<string, object> vars) | 443 | public void VarDump(Dictionary<string, object> vars) |
519 | { | 444 | { |
520 | // m_log.Info("Variable dump for script "+ m_ItemID.ToString()); | 445 | // m_log.Info("Variable dump for script "+ ItemID.ToString()); |
521 | // foreach (KeyValuePair<string, object> v in vars) | 446 | // foreach (KeyValuePair<string, object> v in vars) |
522 | // { | 447 | // { |
523 | // m_log.Info("Variable: "+v.Key+" = "+v.Value.ToString()); | 448 | // m_log.Info("Variable: "+v.Key+" = "+v.Value.ToString()); |
@@ -526,17 +451,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
526 | 451 | ||
527 | public void Start() | 452 | public void Start() |
528 | { | 453 | { |
529 | lock (m_EventQueue) | 454 | lock (EventQueue) |
530 | { | 455 | { |
531 | if (Running) | 456 | if (Running) |
532 | return; | 457 | return; |
533 | 458 | ||
534 | m_RunEvents = true; | 459 | Running = true; |
535 | 460 | ||
536 | if (m_EventQueue.Count > 0) | 461 | if (EventQueue.Count > 0) |
537 | { | 462 | { |
538 | if (m_CurrentWorkItem == null) | 463 | if (m_CurrentWorkItem == null) |
539 | m_CurrentWorkItem = m_Engine.QueueEventHandler(this); | 464 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
540 | // else | 465 | // else |
541 | // m_log.Error("[Script] Tried to start a script that was already queued"); | 466 | // m_log.Error("[Script] Tried to start a script that was already queued"); |
542 | } | 467 | } |
@@ -546,11 +471,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
546 | public bool Stop(int timeout) | 471 | public bool Stop(int timeout) |
547 | { | 472 | { |
548 | // m_log.DebugFormat( | 473 | // m_log.DebugFormat( |
549 | // "[SCRIPT INSTANCE]: Stopping script {0} {1} with timeout {2}", ScriptName, ItemID, timeout); | 474 | // "[SCRIPT INSTANCE]: Stopping script {0} {1} in {2} {3} with timeout {4} {5} {6}", |
475 | // ScriptName, ItemID, PrimName, ObjectID, timeout, m_InSelfDelete, DateTime.Now.Ticks); | ||
550 | 476 | ||
551 | IScriptWorkItem workItem; | 477 | IScriptWorkItem workItem; |
552 | 478 | ||
553 | lock (m_EventQueue) | 479 | lock (EventQueue) |
554 | { | 480 | { |
555 | if (!Running) | 481 | if (!Running) |
556 | return true; | 482 | return true; |
@@ -558,7 +484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
558 | // If we're not running or waiting to run an event then we can safely stop. | 484 | // If we're not running or waiting to run an event then we can safely stop. |
559 | if (m_CurrentWorkItem == null) | 485 | if (m_CurrentWorkItem == null) |
560 | { | 486 | { |
561 | m_RunEvents = false; | 487 | Running = false; |
562 | return true; | 488 | return true; |
563 | } | 489 | } |
564 | 490 | ||
@@ -566,21 +492,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
566 | if (m_CurrentWorkItem.Cancel()) | 492 | if (m_CurrentWorkItem.Cancel()) |
567 | { | 493 | { |
568 | m_CurrentWorkItem = null; | 494 | m_CurrentWorkItem = null; |
569 | m_RunEvents = false; | 495 | Running = false; |
570 | return true; | 496 | return true; |
571 | } | 497 | } |
572 | 498 | ||
573 | workItem = m_CurrentWorkItem; | 499 | workItem = m_CurrentWorkItem; |
574 | m_RunEvents = false; | 500 | Running = false; |
575 | } | 501 | } |
576 | 502 | ||
577 | // Wait for the current event to complete. | 503 | // Wait for the current event to complete. |
578 | if (workItem.Wait(new TimeSpan((long)timeout * 100000))) | 504 | if (!m_InSelfDelete && workItem.Wait(new TimeSpan((long)timeout * 100000))) |
579 | { | 505 | { |
580 | return true; | 506 | return true; |
581 | } | 507 | } |
582 | 508 | ||
583 | lock (m_EventQueue) | 509 | lock (EventQueue) |
584 | { | 510 | { |
585 | workItem = m_CurrentWorkItem; | 511 | workItem = m_CurrentWorkItem; |
586 | } | 512 | } |
@@ -592,12 +518,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
592 | // forcibly abort the work item (this aborts the underlying thread). | 518 | // forcibly abort the work item (this aborts the underlying thread). |
593 | if (!m_InSelfDelete) | 519 | if (!m_InSelfDelete) |
594 | { | 520 | { |
595 | // m_log.ErrorFormat("[SCRIPT INSTANCE]: Aborting script {0} {1}", ScriptName, ItemID); | 521 | // m_log.ErrorFormat( |
522 | // "[SCRIPT INSTANCE]: Aborting script {0} {1} in prim {2} {3} {4} {5}", | ||
523 | // ScriptName, ItemID, PrimName, ObjectID, m_InSelfDelete, DateTime.Now.Ticks); | ||
596 | 524 | ||
597 | workItem.Abort(); | 525 | workItem.Abort(); |
598 | } | 526 | } |
599 | 527 | ||
600 | lock (m_EventQueue) | 528 | lock (EventQueue) |
601 | { | 529 | { |
602 | m_CurrentWorkItem = null; | 530 | m_CurrentWorkItem = null; |
603 | } | 531 | } |
@@ -630,7 +558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
630 | public void PostEvent(EventParams data) | 558 | public void PostEvent(EventParams data) |
631 | { | 559 | { |
632 | // m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}", | 560 | // m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}", |
633 | // m_PrimName, m_ScriptName, data.EventName, m_State); | 561 | // PrimName, ScriptName, data.EventName, State); |
634 | 562 | ||
635 | if (!Running) | 563 | if (!Running) |
636 | return; | 564 | return; |
@@ -645,9 +573,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
645 | m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks; | 573 | m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks; |
646 | } | 574 | } |
647 | 575 | ||
648 | lock (m_EventQueue) | 576 | lock (EventQueue) |
649 | { | 577 | { |
650 | if (m_EventQueue.Count >= m_MaxScriptQueue) | 578 | if (EventQueue.Count >= m_MaxScriptQueue) |
651 | return; | 579 | return; |
652 | 580 | ||
653 | if (data.EventName == "timer") | 581 | if (data.EventName == "timer") |
@@ -691,11 +619,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
691 | m_CollisionInQueue = true; | 619 | m_CollisionInQueue = true; |
692 | } | 620 | } |
693 | 621 | ||
694 | m_EventQueue.Enqueue(data); | 622 | EventQueue.Enqueue(data); |
695 | 623 | ||
696 | if (m_CurrentWorkItem == null) | 624 | if (m_CurrentWorkItem == null) |
697 | { | 625 | { |
698 | m_CurrentWorkItem = m_Engine.QueueEventHandler(this); | 626 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
699 | } | 627 | } |
700 | } | 628 | } |
701 | } | 629 | } |
@@ -706,6 +634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
706 | /// <returns></returns> | 634 | /// <returns></returns> |
707 | public object EventProcessor() | 635 | public object EventProcessor() |
708 | { | 636 | { |
637 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | ||
638 | if (!Running) | ||
639 | return 0; | ||
640 | |||
709 | lock (m_Script) | 641 | lock (m_Script) |
710 | { | 642 | { |
711 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 643 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
@@ -715,14 +647,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
715 | 647 | ||
716 | EventParams data = null; | 648 | EventParams data = null; |
717 | 649 | ||
718 | lock (m_EventQueue) | 650 | lock (EventQueue) |
719 | { | 651 | { |
720 | data = (EventParams) m_EventQueue.Dequeue(); | 652 | data = (EventParams)EventQueue.Dequeue(); |
721 | if (data == null) // Shouldn't happen | 653 | if (data == null) // Shouldn't happen |
722 | { | 654 | { |
723 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 655 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
724 | { | 656 | { |
725 | m_CurrentWorkItem = m_Engine.QueueEventHandler(this); | 657 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
726 | } | 658 | } |
727 | else | 659 | else |
728 | { | 660 | { |
@@ -749,28 +681,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
749 | if (data.EventName == "state") // Hardcoded state change | 681 | if (data.EventName == "state") // Hardcoded state change |
750 | { | 682 | { |
751 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 683 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
752 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 684 | // PrimName, ScriptName, data.Params[0].ToString()); |
753 | m_State = data.Params[0].ToString(); | 685 | State = data.Params[0].ToString(); |
754 | AsyncCommandManager.RemoveScript(m_Engine, | 686 | AsyncCommandManager.RemoveScript(Engine, |
755 | m_LocalID, m_ItemID); | 687 | LocalID, ItemID); |
756 | 688 | ||
757 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 689 | SceneObjectPart part = Engine.World.GetSceneObjectPart( |
758 | m_LocalID); | 690 | LocalID); |
759 | if (part != null) | 691 | if (part != null) |
760 | { | 692 | { |
761 | part.SetScriptEvents(m_ItemID, | 693 | part.SetScriptEvents(ItemID, |
762 | (int)m_Script.GetStateEventFlags(State)); | 694 | (int)m_Script.GetStateEventFlags(State)); |
763 | } | 695 | } |
764 | } | 696 | } |
765 | else | 697 | else |
766 | { | 698 | { |
767 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 699 | if (Engine.World.PipeEventsForScript(LocalID) || |
768 | data.EventName == "control") // Don't freeze avies! | 700 | data.EventName == "control") // Don't freeze avies! |
769 | { | 701 | { |
770 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 702 | SceneObjectPart part = Engine.World.GetSceneObjectPart( |
771 | m_LocalID); | 703 | LocalID); |
772 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | 704 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
773 | // m_PrimName, m_ScriptName, data.EventName, m_State); | 705 | // PrimName, ScriptName, data.EventName, State); |
774 | 706 | ||
775 | try | 707 | try |
776 | { | 708 | { |
@@ -812,7 +744,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
812 | 744 | ||
813 | if (text.Length > 1000) | 745 | if (text.Length > 1000) |
814 | text = text.Substring(0, 1000); | 746 | text = text.Substring(0, 1000); |
815 | m_Engine.World.SimChat(Utils.StringToBytes(text), | 747 | Engine.World.SimChat(Utils.StringToBytes(text), |
816 | ChatTypeEnum.DebugChannel, 2147483647, | 748 | ChatTypeEnum.DebugChannel, 2147483647, |
817 | part.AbsolutePosition, | 749 | part.AbsolutePosition, |
818 | part.Name, part.UUID, false); | 750 | part.Name, part.UUID, false); |
@@ -834,26 +766,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
834 | { | 766 | { |
835 | m_InSelfDelete = true; | 767 | m_InSelfDelete = true; |
836 | if (part != null) | 768 | if (part != null) |
837 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 769 | Engine.World.DeleteSceneObject(part.ParentGroup, false); |
838 | } | 770 | } |
839 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 771 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) |
840 | { | 772 | { |
841 | m_InSelfDelete = true; | 773 | m_InSelfDelete = true; |
842 | if (part != null) | 774 | if (part != null) |
843 | part.Inventory.RemoveInventoryItem(m_ItemID); | 775 | part.Inventory.RemoveInventoryItem(ItemID); |
844 | } | 776 | } |
845 | } | 777 | } |
846 | } | 778 | } |
847 | } | 779 | } |
848 | 780 | ||
849 | |||
850 | // If there are more events and we are currently running and not shutting down, then ask the | 781 | // If there are more events and we are currently running and not shutting down, then ask the |
851 | // script engine to run the next event. | 782 | // script engine to run the next event. |
852 | lock (m_EventQueue) | 783 | lock (EventQueue) |
853 | { | 784 | { |
854 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 785 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
855 | { | 786 | { |
856 | m_CurrentWorkItem = m_Engine.QueueEventHandler(this); | 787 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
857 | } | 788 | } |
858 | else | 789 | else |
859 | { | 790 | { |
@@ -886,15 +817,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
886 | ReleaseControls(); | 817 | ReleaseControls(); |
887 | 818 | ||
888 | Stop(0); | 819 | Stop(0); |
889 | SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); | 820 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
890 | part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0; | 821 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
891 | part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; | 822 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
892 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 823 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
893 | m_EventQueue.Clear(); | 824 | EventQueue.Clear(); |
894 | m_Script.ResetVars(); | 825 | m_Script.ResetVars(); |
895 | m_State = "default"; | 826 | State = "default"; |
896 | 827 | ||
897 | part.SetScriptEvents(m_ItemID, | 828 | part.SetScriptEvents(ItemID, |
898 | (int)m_Script.GetStateEventFlags(State)); | 829 | (int)m_Script.GetStateEventFlags(State)); |
899 | if (running) | 830 | if (running) |
900 | Start(); | 831 | Start(); |
@@ -911,16 +842,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
911 | ReleaseControls(); | 842 | ReleaseControls(); |
912 | 843 | ||
913 | m_Script.ResetVars(); | 844 | m_Script.ResetVars(); |
914 | SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); | 845 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
915 | part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0; | 846 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
916 | part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; | 847 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
917 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 848 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
918 | 849 | ||
919 | m_EventQueue.Clear(); | 850 | EventQueue.Clear(); |
920 | m_Script.ResetVars(); | 851 | m_Script.ResetVars(); |
921 | m_State = "default"; | 852 | State = "default"; |
922 | 853 | ||
923 | part.SetScriptEvents(m_ItemID, | 854 | part.SetScriptEvents(ItemID, |
924 | (int)m_Script.GetStateEventFlags(State)); | 855 | (int)m_Script.GetStateEventFlags(State)); |
925 | 856 | ||
926 | if (m_CurrentEvent != "state_entry") | 857 | if (m_CurrentEvent != "state_entry") |
@@ -975,7 +906,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
975 | return; | 906 | return; |
976 | } | 907 | } |
977 | 908 | ||
978 | PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); | 909 | PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); |
979 | 910 | ||
980 | string xml = ScriptSerializer.Serialize(this); | 911 | string xml = ScriptSerializer.Serialize(this); |
981 | 912 | ||
@@ -987,7 +918,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
987 | { | 918 | { |
988 | try | 919 | try |
989 | { | 920 | { |
990 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")); | 921 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); |
991 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 922 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); |
992 | Byte[] buf = enc.GetBytes(xml); | 923 | Byte[] buf = enc.GetBytes(xml); |
993 | fs.Write(buf, 0, buf.Length); | 924 | fs.Write(buf, 0, buf.Length); |
@@ -997,7 +928,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
997 | { | 928 | { |
998 | // m_log.Error("Unable to save xml\n"+e.ToString()); | 929 | // m_log.Error("Unable to save xml\n"+e.ToString()); |
999 | } | 930 | } |
1000 | //if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"))) | 931 | //if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state"))) |
1001 | //{ | 932 | //{ |
1002 | // throw new Exception("Completed persistence save, but no file was created"); | 933 | // throw new Exception("Completed persistence save, but no file was created"); |
1003 | //} | 934 | //} |
@@ -1014,7 +945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1014 | 945 | ||
1015 | public override string ToString() | 946 | public override string ToString() |
1016 | { | 947 | { |
1017 | return String.Format("{0} {1} on {2}", m_ScriptName, m_ItemID, m_PrimName); | 948 | return String.Format("{0} {1} on {2}", ScriptName, ItemID, PrimName); |
1018 | } | 949 | } |
1019 | 950 | ||
1020 | string FormatException(Exception e) | 951 | string FormatException(Exception e) |
@@ -1082,7 +1013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1082 | 1013 | ||
1083 | // Force an update of the in-memory plugin data | 1014 | // Force an update of the in-memory plugin data |
1084 | // | 1015 | // |
1085 | PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); | 1016 | PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); |
1086 | 1017 | ||
1087 | return ScriptSerializer.Serialize(this); | 1018 | return ScriptSerializer.Serialize(this); |
1088 | } | 1019 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index ab41873..105d97d 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -176,12 +176,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
176 | get { return m_ConfigSource; } | 176 | get { return m_ConfigSource; } |
177 | } | 177 | } |
178 | 178 | ||
179 | /// <summary> | ||
180 | /// Event fired after the script engine has finished removing a script. | ||
181 | /// </summary> | ||
179 | public event ScriptRemoved OnScriptRemoved; | 182 | public event ScriptRemoved OnScriptRemoved; |
183 | |||
184 | /// <summary> | ||
185 | /// Event fired after the script engine has finished removing a script from an object. | ||
186 | /// </summary> | ||
180 | public event ObjectRemoved OnObjectRemoved; | 187 | public event ObjectRemoved OnObjectRemoved; |
181 | 188 | ||
182 | // | ||
183 | // IRegionModule functions | ||
184 | // | ||
185 | public void Initialise(IConfigSource configSource) | 189 | public void Initialise(IConfigSource configSource) |
186 | { | 190 | { |
187 | if (configSource.Configs["XEngine"] == null) | 191 | if (configSource.Configs["XEngine"] == null) |
@@ -1118,7 +1122,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1118 | } | 1122 | } |
1119 | 1123 | ||
1120 | instance.ClearQueue(); | 1124 | instance.ClearQueue(); |
1121 | instance.Stop(0); | 1125 | |
1126 | // Give the script some time to finish processing its last event. Simply aborting the script thread can | ||
1127 | // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort. | ||
1128 | instance.Stop(1000); | ||
1129 | |||
1122 | // bool objectRemoved = false; | 1130 | // bool objectRemoved = false; |
1123 | 1131 | ||
1124 | lock (m_PrimObjects) | 1132 | lock (m_PrimObjects) |
@@ -1149,14 +1157,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1149 | UnloadAppDomain(instance.AppDomain); | 1157 | UnloadAppDomain(instance.AppDomain); |
1150 | } | 1158 | } |
1151 | 1159 | ||
1152 | instance = null; | ||
1153 | |||
1154 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 1160 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
1155 | if (handlerObjectRemoved != null) | 1161 | if (handlerObjectRemoved != null) |
1156 | { | 1162 | handlerObjectRemoved(instance.ObjectID); |
1157 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
1158 | handlerObjectRemoved(part.UUID); | ||
1159 | } | ||
1160 | 1163 | ||
1161 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 1164 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
1162 | if (handlerScriptRemoved != null) | 1165 | if (handlerScriptRemoved != null) |