aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2015-01-26 23:16:06 +0000
committerJustin Clark-Casey (justincc)2015-01-26 23:31:46 +0000
commit1bed3aff0b21102f04481b2345a0d804c2e5716c (patch)
tree36c9b6fb997849ca0831e690d9c4b210789b680b /OpenSim/Region
parentBulletSim: update DLLs, SOs, and dylib with latest versions. (diff)
downloadopensim-SC_OLD-1bed3aff0b21102f04481b2345a0d804c2e5716c.zip
opensim-SC_OLD-1bed3aff0b21102f04481b2345a0d804c2e5716c.tar.gz
opensim-SC_OLD-1bed3aff0b21102f04481b2345a0d804c2e5716c.tar.bz2
opensim-SC_OLD-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')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs109
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs118
4 files changed, 147 insertions, 91 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 52a34a6..af324bf 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -291,7 +291,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
291 string source, string asset, UUID ownerUUID, bool alwaysRecompile, 291 string source, string asset, UUID ownerUUID, bool alwaysRecompile,
292 out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) 292 out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
293 { 293 {
294// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); 294// m_log.DebugFormat("[Compiler]: Checking script for asset {0} in {1}\n{2}", asset, m_scriptEngine.World.Name, source);
295 295
296 IScriptModuleComms comms = m_scriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); 296 IScriptModuleComms comms = m_scriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
297 297
@@ -300,12 +300,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
300 300
301 assembly = GetCompilerOutput(asset); 301 assembly = GetCompilerOutput(asset);
302 302
303// m_log.DebugFormat("[Compiler]: Retrieved assembly {0} for asset {1} in {2}", assembly, asset, m_scriptEngine.World.Name);
304
303 CheckOrCreateScriptsDirectory(); 305 CheckOrCreateScriptsDirectory();
304 306
305 // Don't recompile if we're not forced to and we already have it 307 // Don't recompile if we're not forced to and we already have it
306 // Performing 3 file exists tests for every script can still be slow 308 // Performing 3 file exists tests for every script can still be slow
307 if (!alwaysRecompile && File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) 309 if (!alwaysRecompile && File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map"))
308 { 310 {
311// m_log.DebugFormat("[Compiler]: Found existing assembly {0} for asset {1} in {2}", assembly, asset, m_scriptEngine.World.Name);
312
309 // If we have already read this linemap file, then it will be in our dictionary. 313 // If we have already read this linemap file, then it will be in our dictionary.
310 // Don't build another copy of the dictionary (saves memory) and certainly 314 // Don't build another copy of the dictionary (saves memory) and certainly
311 // don't keep reading the same file from disk multiple times. 315 // don't keep reading the same file from disk multiple times.
@@ -315,6 +319,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
315 return; 319 return;
316 } 320 }
317 321
322// m_log.DebugFormat("[Compiler]: Compiling assembly {0} for asset {1} in {2}", assembly, asset, m_scriptEngine.World.Name);
323
318 if (source == String.Empty) 324 if (source == String.Empty)
319 throw new Exception("Cannot find script assembly and no script text present"); 325 throw new Exception("Cannot find script assembly and no script text present");
320 326
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 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
index 1fff6ba..5b9794b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
@@ -76,6 +76,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
76 //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); 76 //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
77// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); 77// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
78 m_xEngine = new OpenSim.Region.ScriptEngine.XEngine.XEngine(); 78 m_xEngine = new OpenSim.Region.ScriptEngine.XEngine.XEngine();
79 m_xEngine.DebugLevel = 1;
79 80
80 IniConfigSource configSource = new IniConfigSource(); 81 IniConfigSource configSource = new IniConfigSource();
81 82
@@ -336,7 +337,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
336 public void TestStopOnInfiniteJumpLoop() 337 public void TestStopOnInfiniteJumpLoop()
337 { 338 {
338 TestHelpers.InMethod(); 339 TestHelpers.InMethod();
339// TestHelpers.EnableLogging(); 340 TestHelpers.EnableLogging();
340 341
341 string script = 342 string script =
342@"default 343@"default
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index c8029d7..dd5bc0d 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1327,22 +1327,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1327 } 1327 }
1328 m_DomainScripts[appDomain].Add(itemID); 1328 m_DomainScripts[appDomain].Add(itemID);
1329 1329
1330 Assembly scriptAssembly = m_AppDomains[appDomain].Load(Path.GetFileNameWithoutExtension(assemblyPath)); 1330 IScript scriptObj = null;
1331 bool recompile = false; 1331 bool recompile = false;
1332 bool abortAfterRecompile = false;
1333 EventWaitHandle coopSleepHandle = null;
1334 bool coopTerminationForThisScript;
1335 string typeName;
1336
1337 // Set up assembly name to point to the appropriate scriptEngines directory
1338 AssemblyName assemblyName = new AssemblyName(Path.GetFileNameWithoutExtension(assemblyPath));
1339 assemblyName.CodeBase = Path.GetDirectoryName(assemblyPath);
1332 1340
1333 if (m_coopTermination) 1341 if (m_coopTermination)
1334 { 1342 {
1335 Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); 1343 try
1344 {
1345 coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset);
1346
1347 scriptObj
1348 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1349 assemblyName.FullName,
1350 "SecondLife.XEngineScript",
1351 false,
1352 BindingFlags.Default,
1353 null,
1354 new object[] { coopSleepHandle },
1355 null,
1356 null);
1357
1358 coopTerminationForThisScript = true;
1359 }
1360 catch (TypeLoadException e)
1361 {
1362 coopSleepHandle = null;
1336 1363
1337 if (scriptType == null) 1364 try
1365 {
1366 scriptObj
1367 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1368 assemblyName.FullName,
1369 "SecondLife.Script",
1370 false,
1371 BindingFlags.Default,
1372 null,
1373 null,
1374 null,
1375 null);
1376 }
1377 catch (Exception e2)
1378 {
1379 m_log.Error(
1380 string.Format(
1381 "[XENGINE]: Could not load previous SecondLife.Script from assembly {0} in {1}. Recompiling then aborting. Exception ",
1382 assemblyName.FullName, World.Name),
1383 e2);
1384
1385 abortAfterRecompile = true;
1386 }
1387
1388 coopTerminationForThisScript = false;
1338 recompile = true; 1389 recompile = true;
1390 }
1339 } 1391 }
1340 else 1392 else
1341 { 1393 {
1342 Type scriptType = scriptAssembly.GetType("SecondLife.Script"); 1394 try
1395 {
1396 scriptObj
1397 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1398 assemblyName.FullName,
1399 "SecondLife.Script",
1400 false,
1401 BindingFlags.Default,
1402 null,
1403 null,
1404 null,
1405 null);
1406
1407 coopTerminationForThisScript = false;
1408 }
1409 catch (TypeLoadException e)
1410 {
1411 coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset);
1412
1413 try
1414 {
1415 scriptObj
1416 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1417 assemblyName.FullName,
1418 "SecondLife.XEngineScript",
1419 false,
1420 BindingFlags.Default,
1421 null,
1422 new object[] { new XEngineEventWaitHandle(false, EventResetMode.AutoReset) },
1423 null,
1424 null);
1425 }
1426 catch (Exception e2)
1427 {
1428 m_log.Error(
1429 string.Format(
1430 "[XENGINE]: Could not load previous SecondLife.XEngineScript from assembly {0} in {1}. Recompiling then aborting. Exception ",
1431 assemblyName.FullName, World.Name),
1432 e2);
1343 1433
1344 if (scriptType == null) 1434 abortAfterRecompile = true;
1435 }
1436
1437 coopTerminationForThisScript = true;
1345 recompile = true; 1438 recompile = true;
1439 }
1346 } 1440 }
1347 1441
1348 // If we are loading all scripts into the same AppDomain, then we can't reload the DLL in this 1442 // If we are loading all scripts into the same AppDomain, then we can't reload the DLL in this
@@ -1351,12 +1445,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1351 if (recompile) 1445 if (recompile)
1352 { 1446 {
1353 m_log.DebugFormat( 1447 m_log.DebugFormat(
1354 "[XEngine]: Recompiling script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5} to switch it to {6} termination. Will be active on next restart.", 1448 "[XEngine]: Recompiling script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5} to switch it to {6} termination. New termination will be active on next restart.",
1355 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, 1449 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
1356 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.Name, 1450 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.Name,
1357 m_coopTermination ? "co-op" : "abort"); 1451 m_coopTermination ? "co-op" : "abort");
1358 1452
1359 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, true, out assemblyPath, out linemap); 1453 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, true, out assemblyPath, out linemap);
1454
1455 if (abortAfterRecompile)
1456 return false;
1360 } 1457 }
1361 1458
1362 instance = new ScriptInstance(this, part, 1459 instance = new ScriptInstance(this, part,
@@ -1364,10 +1461,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1364 startParam, postOnRez, 1461 startParam, postOnRez,
1365 m_MaxScriptQueue); 1462 m_MaxScriptQueue);
1366 1463
1367 if (!instance.Load( 1464 if (
1368 m_AppDomains[appDomain], scriptAssembly, 1465 !instance.Load(
1369 Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource)) 1466 scriptObj, coopSleepHandle, assemblyPath,
1370 return false; 1467 Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript))
1468 return false;
1371 1469
1372// if (DebugLevel >= 1) 1470// if (DebugLevel >= 1)
1373// m_log.DebugFormat( 1471// m_log.DebugFormat(