diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 98 |
1 files changed, 74 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 75aea2b..5bc585e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -251,7 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
251 | /// <param name='dom'></param> | 251 | /// <param name='dom'></param> |
252 | /// <param name='assembly'></param> | 252 | /// <param name='assembly'></param> |
253 | /// <param name='stateSource'></param> | 253 | /// <param name='stateSource'></param> |
254 | public void Load(AppDomain dom, string assembly, StateSource stateSource) | 254 | /// <returns>false if load failed, true if suceeded</returns> |
255 | public bool Load(AppDomain dom, string assembly, StateSource stateSource) | ||
255 | { | 256 | { |
256 | m_Assembly = assembly; | 257 | m_Assembly = assembly; |
257 | m_stateSource = stateSource; | 258 | m_stateSource = stateSource; |
@@ -266,14 +267,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
266 | 267 | ||
267 | try | 268 | try |
268 | { | 269 | { |
270 | object[] constructorParams; | ||
271 | |||
272 | Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly)); | ||
273 | Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); | ||
274 | |||
275 | if (scriptType != null) | ||
276 | { | ||
277 | constructorParams = new object[] { m_coopSleepHandle }; | ||
278 | } | ||
279 | else if (!m_coopTermination) | ||
280 | { | ||
281 | scriptType = scriptAssembly.GetType("SecondLife.Script"); | ||
282 | constructorParams = null; | ||
283 | } | ||
284 | else | ||
285 | { | ||
286 | m_log.ErrorFormat( | ||
287 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. You must remove all existing {6}* script DLL files before using enabling co-op termination" | ||
288 | + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run" | ||
289 | + " or by deleting these files manually.", | ||
290 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, assembly); | ||
291 | |||
292 | return false; | ||
293 | } | ||
294 | |||
295 | // m_log.DebugFormat( | ||
296 | // "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}", | ||
297 | // scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name); | ||
298 | |||
269 | if (dom != System.AppDomain.CurrentDomain) | 299 | if (dom != System.AppDomain.CurrentDomain) |
270 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( | 300 | m_Script |
301 | = (IScript)dom.CreateInstanceAndUnwrap( | ||
271 | Path.GetFileNameWithoutExtension(assembly), | 302 | Path.GetFileNameWithoutExtension(assembly), |
272 | "SecondLife.Script"); | 303 | scriptType.FullName, |
304 | false, | ||
305 | BindingFlags.Default, | ||
306 | null, | ||
307 | constructorParams, | ||
308 | null, | ||
309 | null); | ||
273 | else | 310 | else |
274 | m_Script = (IScript)Assembly.Load( | 311 | m_Script |
275 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( | 312 | = (IScript)scriptAssembly.CreateInstance( |
276 | "SecondLife.Script"); | 313 | scriptType.FullName, |
314 | false, | ||
315 | BindingFlags.Default, | ||
316 | null, | ||
317 | constructorParams, | ||
318 | null, | ||
319 | null); | ||
277 | 320 | ||
278 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 321 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
279 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 322 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
@@ -282,8 +325,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
282 | catch (Exception e) | 325 | catch (Exception e) |
283 | { | 326 | { |
284 | m_log.ErrorFormat( | 327 | m_log.ErrorFormat( |
285 | "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", | 328 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}", |
286 | assembly, e.Message, e.StackTrace); | 329 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, assembly, e.Message, e.StackTrace); |
330 | |||
331 | return false; | ||
287 | } | 332 | } |
288 | 333 | ||
289 | try | 334 | try |
@@ -301,10 +346,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
301 | catch (Exception e) | 346 | catch (Exception e) |
302 | { | 347 | { |
303 | m_log.ErrorFormat( | 348 | m_log.ErrorFormat( |
304 | "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", | 349 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error initializing script instance. Exception {6}{7}", |
305 | assembly, e.Message, e.StackTrace); | 350 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, e.Message, e.StackTrace); |
306 | 351 | ||
307 | return; | 352 | return false; |
308 | } | 353 | } |
309 | 354 | ||
310 | m_SaveState = true; | 355 | m_SaveState = true; |
@@ -357,15 +402,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
357 | else | 402 | else |
358 | { | 403 | { |
359 | m_log.WarnFormat( | 404 | m_log.WarnFormat( |
360 | "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). Memory limit exceeded", | 405 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.", |
361 | savedState, ScriptName, ItemID, PrimName, ObjectID, assembly); | 406 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); |
362 | } | 407 | } |
363 | } | 408 | } |
364 | catch (Exception e) | 409 | catch (Exception e) |
365 | { | 410 | { |
366 | m_log.ErrorFormat( | 411 | m_log.ErrorFormat( |
367 | "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). XML is {6}. Exception {7}{8}", | 412 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. XML is {7}. Exception {8}{9}", |
368 | savedState, ScriptName, ItemID, PrimName, ObjectID, assembly, xml, e.Message, e.StackTrace); | 413 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState, xml, e.Message, e.StackTrace); |
369 | } | 414 | } |
370 | } | 415 | } |
371 | // else | 416 | // else |
@@ -376,6 +421,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
376 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); | 421 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); |
377 | 422 | ||
378 | // } | 423 | // } |
424 | |||
425 | return true; | ||
379 | } | 426 | } |
380 | 427 | ||
381 | public void Init() | 428 | public void Init() |
@@ -552,9 +599,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
552 | } | 599 | } |
553 | else | 600 | else |
554 | { | 601 | { |
555 | m_log.DebugFormat( | 602 | if (DebugLevel >= 1) |
556 | "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}", | 603 | m_log.DebugFormat( |
557 | ScriptName, ItemID, PrimName, ObjectID); | 604 | "[SCRIPT INSTANCE]: Co-operatively stopping script {0} {1} in {2} {3}", |
605 | ScriptName, ItemID, PrimName, ObjectID); | ||
558 | 606 | ||
559 | // This will terminate the event on next handle check by the script. | 607 | // This will terminate the event on next handle check by the script. |
560 | m_coopSleepHandle.Set(); | 608 | m_coopSleepHandle.Set(); |
@@ -563,9 +611,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
563 | // checking is implemented. May want to allow a shorter timeout option later. | 611 | // checking is implemented. May want to allow a shorter timeout option later. |
564 | if (workItem.Wait(TimeSpan.MaxValue)) | 612 | if (workItem.Wait(TimeSpan.MaxValue)) |
565 | { | 613 | { |
566 | m_log.DebugFormat( | 614 | if (DebugLevel >= 1) |
567 | "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}", | 615 | m_log.DebugFormat( |
568 | ScriptName, ItemID, PrimName, ObjectID); | 616 | "[SCRIPT INSTANCE]: Co-operatively stopped script {0} {1} in {2} {3}", |
617 | ScriptName, ItemID, PrimName, ObjectID); | ||
569 | 618 | ||
570 | return true; | 619 | return true; |
571 | } | 620 | } |
@@ -876,9 +925,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
876 | } | 925 | } |
877 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) | 926 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException)) |
878 | { | 927 | { |
879 | m_log.DebugFormat( | 928 | if (DebugLevel >= 1) |
880 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", | 929 | m_log.DebugFormat( |
881 | PrimName, ScriptName, data.EventName, State); | 930 | "[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.", |
931 | PrimName, ScriptName, data.EventName, State); | ||
882 | } | 932 | } |
883 | } | 933 | } |
884 | } | 934 | } |