diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 118 |
1 files changed, 108 insertions, 10 deletions
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( |