diff options
author | Justin Clark-Casey (justincc) | 2015-01-26 23:16:06 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2015-01-26 23:31:46 +0000 |
commit | 1bed3aff0b21102f04481b2345a0d804c2e5716c (patch) | |
tree | 36c9b6fb997849ca0831e690d9c4b210789b680b /OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |
parent | BulletSim: update DLLs, SOs, and dylib with latest versions. (diff) | |
download | opensim-SC-1bed3aff0b21102f04481b2345a0d804c2e5716c.zip opensim-SC-1bed3aff0b21102f04481b2345a0d804c2e5716c.tar.gz opensim-SC-1bed3aff0b21102f04481b2345a0d804c2e5716c.tar.bz2 opensim-SC-1bed3aff0b21102f04481b2345a0d804c2e5716c.tar.xz |
On a multi-region simulator when AppDomain = true, make sure the DLL from the appropriate script engines subdir is loaded rather than always that of the first engine to load the DLL.
This resolves a DLL load failure on my Linux box when an attachment script was present on another region before the avatar arrived.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 109 |
1 files changed, 30 insertions, 79 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index b4b4fa0..5ff56a1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -259,65 +259,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
259 | /// </param> | 259 | /// </param> |
260 | /// <param name='stateSource'></param> | 260 | /// <param name='stateSource'></param> |
261 | /// <returns>false if load failed, true if suceeded</returns> | 261 | /// <returns>false if load failed, true if suceeded</returns> |
262 | public bool Load(AppDomain dom, Assembly scriptAssembly, string dataPath, StateSource stateSource) | 262 | public bool Load( |
263 | IScript script, EventWaitHandle coopSleepHandle, string assemblyPath, | ||
264 | string dataPath, StateSource stateSource, bool coopTermination) | ||
263 | { | 265 | { |
264 | m_assemblyPath = scriptAssembly.Location; | 266 | m_Script = script; |
267 | m_coopSleepHandle = coopSleepHandle; | ||
268 | m_assemblyPath = assemblyPath; | ||
265 | m_dataPath = dataPath; | 269 | m_dataPath = dataPath; |
266 | m_stateSource = stateSource; | 270 | m_stateSource = stateSource; |
267 | 271 | m_coopTermination = coopTermination; | |
268 | try | ||
269 | { | ||
270 | object[] constructorParams; | ||
271 | Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); | ||
272 | |||
273 | if (scriptType != null) | ||
274 | { | ||
275 | m_coopTermination = true; | ||
276 | m_coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset); | ||
277 | constructorParams = new object[] { m_coopSleepHandle }; | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | m_coopTermination = false; | ||
282 | scriptType = scriptAssembly.GetType("SecondLife.Script"); | ||
283 | constructorParams = null; | ||
284 | } | ||
285 | |||
286 | if (dom != System.AppDomain.CurrentDomain) | ||
287 | m_Script | ||
288 | = (IScript)dom.CreateInstanceAndUnwrap( | ||
289 | Path.GetFileNameWithoutExtension(m_assemblyPath), | ||
290 | scriptType.FullName, | ||
291 | false, | ||
292 | BindingFlags.Default, | ||
293 | null, | ||
294 | constructorParams, | ||
295 | null, | ||
296 | null, | ||
297 | null); | ||
298 | else | ||
299 | m_Script | ||
300 | = (IScript)scriptAssembly.CreateInstance( | ||
301 | scriptType.FullName, | ||
302 | false, | ||
303 | BindingFlags.Default, | ||
304 | null, | ||
305 | constructorParams, | ||
306 | null, | ||
307 | null); | ||
308 | |||
309 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | ||
310 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | ||
311 | // lease.Register(this); | ||
312 | } | ||
313 | catch (Exception e) | ||
314 | { | ||
315 | m_log.ErrorFormat( | ||
316 | "[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}", | ||
317 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, scriptAssembly.Location, e.Message, e.StackTrace); | ||
318 | |||
319 | return false; | ||
320 | } | ||
321 | 272 | ||
322 | ApiManager am = new ApiManager(); | 273 | ApiManager am = new ApiManager(); |
323 | 274 | ||
@@ -334,7 +285,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
334 | m_Script.InitApi(kv.Key, kv.Value); | 285 | m_Script.InitApi(kv.Key, kv.Value); |
335 | } | 286 | } |
336 | 287 | ||
337 | // // m_log.Debug("[Script] Script instance created"); | 288 | // // m_log.Debug("[Script] Script instance created"); |
338 | 289 | ||
339 | Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); | 290 | Part.SetScriptEvents(ItemID, (int)m_Script.GetStateEventFlags(State)); |
340 | } | 291 | } |
@@ -352,9 +303,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
352 | 303 | ||
353 | if (File.Exists(savedState)) | 304 | if (File.Exists(savedState)) |
354 | { | 305 | { |
355 | // m_log.DebugFormat( | 306 | // m_log.DebugFormat( |
356 | // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", | 307 | // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", |
357 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); | 308 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); |
358 | 309 | ||
359 | string xml = String.Empty; | 310 | string xml = String.Empty; |
360 | 311 | ||
@@ -375,13 +326,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
375 | ScriptSerializer.Deserialize(xml, this); | 326 | ScriptSerializer.Deserialize(xml, this); |
376 | 327 | ||
377 | AsyncCommandManager.CreateFromData(Engine, | 328 | AsyncCommandManager.CreateFromData(Engine, |
378 | LocalID, ItemID, ObjectID, | 329 | LocalID, ItemID, ObjectID, |
379 | PluginData); | 330 | PluginData); |
380 | 331 | ||
381 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); | 332 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); |
382 | 333 | ||
383 | Part.SetScriptEvents(ItemID, | 334 | Part.SetScriptEvents(ItemID, |
384 | (int)m_Script.GetStateEventFlags(State)); | 335 | (int)m_Script.GetStateEventFlags(State)); |
385 | 336 | ||
386 | if (!Running) | 337 | if (!Running) |
387 | m_startOnInit = false; | 338 | m_startOnInit = false; |
@@ -401,26 +352,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
401 | if (!StatePersistedHere) | 352 | if (!StatePersistedHere) |
402 | RemoveState(); | 353 | RemoveState(); |
403 | } | 354 | } |
404 | // else | 355 | // else |
405 | // { | 356 | // { |
406 | // m_log.WarnFormat( | 357 | // m_log.WarnFormat( |
407 | // "[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.", | 358 | // "[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.", |
408 | // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); | 359 | // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); |
409 | // } | 360 | // } |
410 | } | 361 | } |
411 | catch (Exception e) | 362 | catch (Exception e) |
412 | { | 363 | { |
413 | m_log.ErrorFormat( | 364 | m_log.ErrorFormat( |
414 | "[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}", | 365 | "[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}", |
415 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState, xml, e.Message, e.StackTrace); | 366 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState, xml, e.Message, e.StackTrace); |
416 | } | 367 | } |
417 | } | 368 | } |
418 | // else | 369 | // else |
419 | // { | 370 | // { |
420 | // m_log.DebugFormat( | 371 | // m_log.DebugFormat( |
421 | // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", | 372 | // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", |
422 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); | 373 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); |
423 | // } | 374 | // } |
424 | 375 | ||
425 | return true; | 376 | return true; |
426 | } | 377 | } |