aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rwxr-xr-xOpenSim/Region/ScriptEngine/XEngine/XEngine.cs82
1 files changed, 41 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 7822df9..cd5308d 100755
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -131,9 +131,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
131 /// It appears that if a script thread is aborted whilst it is holding ReaderWriterLockSlim (possibly the write 131 /// It appears that if a script thread is aborted whilst it is holding ReaderWriterLockSlim (possibly the write
132 /// lock) then the lock is not properly released. This causes mono 2.6, 2.10 and possibly 132 /// lock) then the lock is not properly released. This causes mono 2.6, 2.10 and possibly
133 /// later to crash, sometimes with symptoms such as a leap to 100% script usage and a vm thead dump showing 133 /// later to crash, sometimes with symptoms such as a leap to 100% script usage and a vm thead dump showing
134 /// all threads waiting on release of ReaderWriterLockSlim write thread which none of the threads listed 134 /// all threads waiting on release of ReaderWriterLockSlim write thread which none of the threads listed
135 /// actually hold. 135 /// actually hold.
136 /// 136 ///
137 /// Pausing for event completion reduces the risk of this happening. However, it may be that aborting threads 137 /// Pausing for event completion reduces the risk of this happening. However, it may be that aborting threads
138 /// is not a mono issue per se but rather a risky activity in itself in an AppDomain that is not immediately 138 /// is not a mono issue per se but rather a risky activity in itself in an AppDomain that is not immediately
139 /// shutting down. 139 /// shutting down.
@@ -307,7 +307,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
307 m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); 307 m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30);
308 m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); 308 m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false);
309 m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000; 309 m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000;
310 m_WaitForEventCompletionOnScriptStop 310 m_WaitForEventCompletionOnScriptStop
311 = m_ScriptConfig.GetInt("WaitForEventCompletionOnScriptStop", m_WaitForEventCompletionOnScriptStop); 311 = m_ScriptConfig.GetInt("WaitForEventCompletionOnScriptStop", m_WaitForEventCompletionOnScriptStop);
312 312
313 m_ScriptEnginesPath = m_ScriptConfig.GetString("ScriptEnginesPath", "ScriptEngines"); 313 m_ScriptEnginesPath = m_ScriptConfig.GetString("ScriptEnginesPath", "ScriptEngines");
@@ -507,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
507 { 507 {
508 string rawItemId; 508 string rawItemId;
509 UUID itemId = UUID.Zero; 509 UUID itemId = UUID.Zero;
510 510
511 if (cmdparams.Length == 2) 511 if (cmdparams.Length == 2)
512 { 512 {
513 IEnumerable<IScriptInstance> scripts = m_Scripts.Values; 513 IEnumerable<IScriptInstance> scripts = m_Scripts.Values;
@@ -520,17 +520,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
520 520
521 return; 521 return;
522 } 522 }
523 523
524 for (int i = 2; i < cmdparams.Length; i++) 524 for (int i = 2; i < cmdparams.Length; i++)
525 { 525 {
526 rawItemId = cmdparams[i]; 526 rawItemId = cmdparams[i];
527 527
528 if (!UUID.TryParse(rawItemId, out itemId)) 528 if (!UUID.TryParse(rawItemId, out itemId))
529 { 529 {
530 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid UUID", rawItemId); 530 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid UUID", rawItemId);
531 continue; 531 continue;
532 } 532 }
533 533
534 if (itemId != UUID.Zero) 534 if (itemId != UUID.Zero)
535 { 535 {
536 IScriptInstance instance = GetInstance(itemId); 536 IScriptInstance instance = GetInstance(itemId);
@@ -816,7 +816,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
816 { 816 {
817 if (!m_Enabled) 817 if (!m_Enabled)
818 return; 818 return;
819 819
820 lock (m_ScriptEngines) 820 lock (m_ScriptEngines)
821 { 821 {
822 if (m_ScriptEngines.Contains(this)) 822 if (m_ScriptEngines.Contains(this))
@@ -978,14 +978,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
978 SceneObjectPart part = 978 SceneObjectPart part =
979 m_Scene.GetSceneObjectPart( 979 m_Scene.GetSceneObjectPart(
980 localID); 980 localID);
981 981
982 TaskInventoryItem item = 982 TaskInventoryItem item =
983 part.Inventory.GetInventoryItem(itemID); 983 part.Inventory.GetInventoryItem(itemID);
984 984
985 ScenePresence presence = 985 ScenePresence presence =
986 m_Scene.GetScenePresence( 986 m_Scene.GetScenePresence(
987 item.OwnerID); 987 item.OwnerID);
988 988
989 if (presence != null) 989 if (presence != null)
990 { 990 {
991 presence.ControllingClient.SendAgentAlertMessage( 991 presence.ControllingClient.SendAgentAlertMessage(
@@ -1073,8 +1073,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1073 { 1073 {
1074 m_log.Error( 1074 m_log.Error(
1075 string.Format( 1075 string.Format(
1076 "[XEngine]: Failure in DoOnRezScriptQueue() for item {0} in {1}. Continuing. Exception ", 1076 "[XEngine]: Failure in DoOnRezScriptQueue() for item {0} in {1}. Continuing. Exception ",
1077 o[1], m_Scene.Name), 1077 o[1], m_Scene.Name),
1078 e); 1078 e);
1079 } 1079 }
1080 } 1080 }
@@ -1091,7 +1091,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1091 } 1091 }
1092 finally 1092 finally
1093 { 1093 {
1094 // FIXME: On failure we must trigger this even if the compile queue is not actually empty so that the 1094 // FIXME: On failure we must trigger this even if the compile queue is not actually empty so that the
1095 // RegionReadyModule is not forever waiting. This event really needs a different name. 1095 // RegionReadyModule is not forever waiting. This event really needs a different name.
1096 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, 1096 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
1097 m_ScriptErrorMessage); 1097 m_ScriptErrorMessage);
@@ -1108,8 +1108,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1108 { 1108 {
1109 m_CurrentCompile = null; 1109 m_CurrentCompile = null;
1110 1110
1111 // This is to avoid a situation where the m_CompileQueue while loop above could complete but 1111 // This is to avoid a situation where the m_CompileQueue while loop above could complete but
1112 // OnRezScript() place a new script on the queue and check m_CurrentCompile = null before we hit 1112 // OnRezScript() place a new script on the queue and check m_CurrentCompile = null before we hit
1113 // this section. 1113 // this section.
1114 if (m_CompileQueue.Count > 0) 1114 if (m_CompileQueue.Count > 0)
1115 m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); 1115 m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null);
@@ -1186,7 +1186,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1186 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assemblyPath, out linemap); 1186 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assemblyPath, out linemap);
1187 1187
1188// m_log.DebugFormat( 1188// m_log.DebugFormat(
1189// "[XENGINE]: Found assembly path {0} onrez {1} in {2}", 1189// "[XENGINE]: Found assembly path {0} onrez {1} in {2}",
1190// assemblyPath, item.ItemID, World.Name); 1190// assemblyPath, item.ItemID, World.Name);
1191 1191
1192 if (!m_AddingAssemblies.ContainsKey(assemblyPath)) { 1192 if (!m_AddingAssemblies.ContainsKey(assemblyPath)) {
@@ -1239,7 +1239,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1239 catch (Exception e) 1239 catch (Exception e)
1240 { 1240 {
1241// m_log.ErrorFormat( 1241// m_log.ErrorFormat(
1242// "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}", 1242// "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}",
1243// itemID, e.Message, e.StackTrace); 1243// itemID, e.Message, e.StackTrace);
1244 1244
1245 // try 1245 // try
@@ -1280,7 +1280,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1280 } 1280 }
1281 1281
1282 // optionaly do not load a assembly on top of a lot of to release memory 1282 // optionaly do not load a assembly on top of a lot of to release memory
1283 // only if logins disable since causes a lot of rubber banding 1283 // only if logins disable since causes a lot of rubber banding
1284 if(m_CompactMemOnLoad && !m_Scene.LoginsEnabled) 1284 if(m_CompactMemOnLoad && !m_Scene.LoginsEnabled)
1285 GC.Collect(2); 1285 GC.Collect(2);
1286 1286
@@ -1323,7 +1323,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1323 { 1323 {
1324 sandbox = AppDomain.CurrentDomain; 1324 sandbox = AppDomain.CurrentDomain;
1325 } 1325 }
1326 1326
1327 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); 1327 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
1328 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); 1328 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
1329 //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); 1329 //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
@@ -1331,7 +1331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1331 //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); 1331 //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
1332 //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; 1332 //sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
1333 //sandbox.SetAppDomainPolicy(sandboxPolicy); 1333 //sandbox.SetAppDomainPolicy(sandboxPolicy);
1334 1334
1335 m_AppDomains[appDomain] = sandbox; 1335 m_AppDomains[appDomain] = sandbox;
1336 1336
1337 m_DomainScripts[appDomain] = new List<UUID>(); 1337 m_DomainScripts[appDomain] = new List<UUID>();
@@ -1341,7 +1341,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1341 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); 1341 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
1342 m_ScriptErrorMessage += "Exception creating app domain:\n"; 1342 m_ScriptErrorMessage += "Exception creating app domain:\n";
1343 m_ScriptFailCount++; 1343 m_ScriptFailCount++;
1344 lock (m_AddingAssemblies) 1344 lock (m_AddingAssemblies)
1345 { 1345 {
1346 m_AddingAssemblies[assemblyPath]--; 1346 m_AddingAssemblies[assemblyPath]--;
1347 } 1347 }
@@ -1364,14 +1364,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1364 { 1364 {
1365 coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset); 1365 coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset);
1366 1366
1367 scriptObj 1367 scriptObj
1368 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( 1368 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1369 assemblyName.FullName, 1369 assemblyName.FullName,
1370 "SecondLife.XEngineScript", 1370 "SecondLife.XEngineScript",
1371 false, 1371 false,
1372 BindingFlags.Default, 1372 BindingFlags.Default,
1373 null, 1373 null,
1374 new object[] { coopSleepHandle }, 1374 new object[] { coopSleepHandle },
1375 null, 1375 null,
1376 null); 1376 null);
1377 1377
@@ -1383,7 +1383,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1383 1383
1384 try 1384 try
1385 { 1385 {
1386 scriptObj 1386 scriptObj
1387 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( 1387 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1388 assemblyName.FullName, 1388 assemblyName.FullName,
1389 "SecondLife.Script", 1389 "SecondLife.Script",
@@ -1398,7 +1398,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1398 { 1398 {
1399 m_log.Error( 1399 m_log.Error(
1400 string.Format( 1400 string.Format(
1401 "[XENGINE]: Could not load previous SecondLife.Script from assembly {0} in {1}. Not starting. Exception ", 1401 "[XENGINE]: Could not load previous SecondLife.Script from assembly {0} in {1}. Not starting. Exception ",
1402 assemblyName.FullName, World.Name), 1402 assemblyName.FullName, World.Name),
1403 e2); 1403 e2);
1404 1404
@@ -1412,7 +1412,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1412 { 1412 {
1413 try 1413 try
1414 { 1414 {
1415 scriptObj 1415 scriptObj
1416 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( 1416 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1417 assemblyName.FullName, 1417 assemblyName.FullName,
1418 "SecondLife.Script", 1418 "SecondLife.Script",
@@ -1432,7 +1432,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1432 1432
1433 try 1433 try
1434 { 1434 {
1435 scriptObj 1435 scriptObj
1436 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap( 1436 = (IScript)m_AppDomains[appDomain].CreateInstanceAndUnwrap(
1437 assemblyName.FullName, 1437 assemblyName.FullName,
1438 "SecondLife.XEngineScript", 1438 "SecondLife.XEngineScript",
@@ -1447,7 +1447,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1447 { 1447 {
1448 m_log.Error( 1448 m_log.Error(
1449 string.Format( 1449 string.Format(
1450 "[XENGINE]: Could not load previous SecondLife.XEngineScript from assembly {0} in {1}. Not starting. Exception ", 1450 "[XENGINE]: Could not load previous SecondLife.XEngineScript from assembly {0} in {1}. Not starting. Exception ",
1451 assemblyName.FullName, World.Name), 1451 assemblyName.FullName, World.Name),
1452 e2); 1452 e2);
1453 1453
@@ -1509,7 +1509,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1509 } 1509 }
1510 1510
1511 1511
1512 lock (m_AddingAssemblies) 1512 lock (m_AddingAssemblies)
1513 { 1513 {
1514 if (!m_Assemblies.ContainsKey(assetID)) 1514 if (!m_Assemblies.ContainsKey(assetID))
1515 m_Assemblies[assetID] = assemblyPath; 1515 m_Assemblies[assetID] = assemblyPath;
@@ -1517,7 +1517,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1517 m_AddingAssemblies[assemblyPath]--; 1517 m_AddingAssemblies[assemblyPath]--;
1518 } 1518 }
1519 1519
1520 if (instance != null) 1520 if (instance != null)
1521 instance.Init(); 1521 instance.Init();
1522 1522
1523 bool runIt; 1523 bool runIt;
@@ -1570,7 +1570,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1570 } 1570 }
1571 1571
1572 if (instance.StatePersistedHere) 1572 if (instance.StatePersistedHere)
1573 instance.RemoveState(); 1573 instance.RemoveState();
1574 1574
1575 instance.DestroyScriptInstance(); 1575 instance.DestroyScriptInstance();
1576 1576
@@ -1622,20 +1622,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1622 // Do not remove assembly files if another instance of the script 1622 // Do not remove assembly files if another instance of the script
1623 // is currently initialising 1623 // is currently initialising
1624 if (!m_AddingAssemblies.ContainsKey(m_Assemblies[assetID]) 1624 if (!m_AddingAssemblies.ContainsKey(m_Assemblies[assetID])
1625 || m_AddingAssemblies[m_Assemblies[assetID]] == 0) 1625 || m_AddingAssemblies[m_Assemblies[assetID]] == 0)
1626 { 1626 {
1627// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); 1627// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]);
1628 try 1628 try
1629 { 1629 {
1630 if (File.Exists(m_Assemblies[assetID])) 1630 if (File.Exists(m_Assemblies[assetID]))
1631 File.Delete(m_Assemblies[assetID]); 1631 File.Delete(m_Assemblies[assetID]);
1632 1632
1633 if (File.Exists(m_Assemblies[assetID]+".text")) 1633 if (File.Exists(m_Assemblies[assetID]+".text"))
1634 File.Delete(m_Assemblies[assetID]+".text"); 1634 File.Delete(m_Assemblies[assetID]+".text");
1635 1635
1636 if (File.Exists(m_Assemblies[assetID]+".mdb")) 1636 if (File.Exists(m_Assemblies[assetID]+".mdb"))
1637 File.Delete(m_Assemblies[assetID]+".mdb"); 1637 File.Delete(m_Assemblies[assetID]+".mdb");
1638 1638
1639 if (File.Exists(m_Assemblies[assetID]+".map")) 1639 if (File.Exists(m_Assemblies[assetID]+".map"))
1640 File.Delete(m_Assemblies[assetID]+".map"); 1640 File.Delete(m_Assemblies[assetID]+".map");
1641 } 1641 }
@@ -1692,7 +1692,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1692 new WorkItemCallback(this.ProcessEventHandler), 1692 new WorkItemCallback(this.ProcessEventHandler),
1693 parms)); 1693 parms));
1694 } 1694 }
1695 1695
1696 /// <summary> 1696 /// <summary>
1697 /// Process a previously posted script event. 1697 /// Process a previously posted script event.
1698 /// </summary> 1698 /// </summary>
@@ -1703,7 +1703,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1703 Culture.SetCurrentCulture(); 1703 Culture.SetCurrentCulture();
1704 1704
1705 IScriptInstance instance = (ScriptInstance) parms; 1705 IScriptInstance instance = (ScriptInstance) parms;
1706 1706
1707// m_log.DebugFormat("[XEngine]: Processing event for {0}", instance); 1707// m_log.DebugFormat("[XEngine]: Processing event for {0}", instance);
1708 1708
1709 return instance.EventProcessor(); 1709 return instance.EventProcessor();
@@ -1736,7 +1736,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1736 instance = m_Scripts[itemID]; 1736 instance = m_Scripts[itemID];
1737 } 1737 }
1738 catch { /* ignore race conditions */ } 1738 catch { /* ignore race conditions */ }
1739 1739
1740 if (instance != null) 1740 if (instance != null)
1741 { 1741 {
1742 instance.PostEvent(p); 1742 instance.PostEvent(p);
@@ -1744,7 +1744,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1744 } 1744 }
1745 } 1745 }
1746 } 1746 }
1747 1747
1748 return result; 1748 return result;
1749 } 1749 }
1750 1750