diff options
author | UbitUmarov | 2015-09-02 19:54:53 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-02 19:54:53 +0100 |
commit | a11edceb00b5b86f825bd957bdac9edb91f893dd (patch) | |
tree | c192eae26f3aadf365a66f32fc6d9ade2f0a0c61 /OpenSim/Region/ScriptEngine/XEngine | |
parent | bad merge? (diff) | |
download | opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.zip opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.gz opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.bz2 opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.xz |
seems to compile ( tests comented out)
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs | 2 | ||||
-rwxr-xr-x | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 381 |
2 files changed, 102 insertions, 281 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs index 2ef4058..07470d6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEnginePersistenceTests.cs | |||
@@ -43,6 +43,7 @@ using OpenSim.Tests.Common; | |||
43 | 43 | ||
44 | namespace OpenSim.Region.ScriptEngine.Tests | 44 | namespace OpenSim.Region.ScriptEngine.Tests |
45 | { | 45 | { |
46 | /* | ||
46 | [TestFixture] | 47 | [TestFixture] |
47 | public class XEnginePersistenceTests : OpenSimTestCase | 48 | public class XEnginePersistenceTests : OpenSimTestCase |
48 | { | 49 | { |
@@ -149,4 +150,5 @@ namespace OpenSim.Region.ScriptEngine.Tests | |||
149 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo); | 150 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo); |
150 | } | 151 | } |
151 | } | 152 | } |
153 | */ | ||
152 | } \ No newline at end of file | 154 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 466c190..78d4ee9 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
32 | using System.Globalization; | 31 | using System.Globalization; |
33 | using System.IO; | 32 | using System.IO; |
34 | using System.Linq; | 33 | using System.Linq; |
@@ -162,8 +161,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
162 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 161 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
163 | new Dictionary<UUID, IScriptInstance>(); | 162 | new Dictionary<UUID, IScriptInstance>(); |
164 | 163 | ||
165 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
166 | |||
167 | // Maps the asset ID to the assembly | 164 | // Maps the asset ID to the assembly |
168 | 165 | ||
169 | private Dictionary<UUID, string> m_Assemblies = | 166 | private Dictionary<UUID, string> m_Assemblies = |
@@ -186,71 +183,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
186 | IWorkItemResult m_CurrentCompile = null; | 183 | IWorkItemResult m_CurrentCompile = null; |
187 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); | 184 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); |
188 | 185 | ||
189 | private void lockScriptsForRead(bool locked) | ||
190 | { | ||
191 | if (locked) | ||
192 | { | ||
193 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
194 | { | ||
195 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
196 | m_scriptsLock.ExitReadLock(); | ||
197 | } | ||
198 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
199 | { | ||
200 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
201 | m_scriptsLock.ExitWriteLock(); | ||
202 | } | ||
203 | |||
204 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
205 | { | ||
206 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
207 | if (m_scriptsLock.IsWriteLockHeld) | ||
208 | { | ||
209 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
216 | { | ||
217 | m_scriptsLock.ExitReadLock(); | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | private void lockScriptsForWrite(bool locked) | ||
222 | { | ||
223 | if (locked) | ||
224 | { | ||
225 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
226 | { | ||
227 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
228 | m_scriptsLock.ExitReadLock(); | ||
229 | } | ||
230 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
231 | { | ||
232 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
233 | m_scriptsLock.ExitWriteLock(); | ||
234 | } | ||
235 | |||
236 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
237 | { | ||
238 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
239 | if (m_scriptsLock.IsWriteLockHeld) | ||
240 | { | ||
241 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
248 | { | ||
249 | m_scriptsLock.ExitWriteLock(); | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | private ScriptEngineConsoleCommands m_consoleCommands; | 186 | private ScriptEngineConsoleCommands m_consoleCommands; |
255 | 187 | ||
256 | public string ScriptEngineName | 188 | public string ScriptEngineName |
@@ -782,31 +714,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
782 | { | 714 | { |
783 | if (!m_Enabled) | 715 | if (!m_Enabled) |
784 | return; | 716 | return; |
785 | lockScriptsForRead(true); | ||
786 | |||
787 | List<IScriptInstance> instancesToDel = new List<IScriptInstance>(m_Scripts.Values); | ||
788 | 717 | ||
789 | // foreach (IScriptInstance instance in m_Scripts.Values) | 718 | lock (m_Scripts) |
790 | foreach (IScriptInstance instance in instancesToDel) | ||
791 | { | 719 | { |
792 | // Force a final state save | 720 | m_log.InfoFormat( |
793 | // | 721 | "[XEngine]: Shutting down {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); |
794 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 722 | |
723 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
795 | { | 724 | { |
796 | <<<<<<< HEAD | ||
797 | // Force a final state save | 725 | // Force a final state save |
798 | // | 726 | // |
799 | try | 727 | try |
800 | { | 728 | { |
801 | if (instance.StatePersistedHere) | 729 | if (instance.StatePersistedHere) |
802 | instance.SaveState(); | 730 | instance.SaveState(); |
803 | ======= | ||
804 | string assembly = m_Assemblies[instance.AssetID]; | ||
805 | |||
806 | try | ||
807 | { | ||
808 | instance.SaveState(assembly); | ||
809 | >>>>>>> avn/ubitvar | ||
810 | } | 731 | } |
811 | catch (Exception e) | 732 | catch (Exception e) |
812 | { | 733 | { |
@@ -816,50 +737,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
816 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) | 737 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) |
817 | , e); | 738 | , e); |
818 | } | 739 | } |
819 | } | ||
820 | 740 | ||
821 | <<<<<<< HEAD | ||
822 | // Clear the event queue and abort the instance thread | 741 | // Clear the event queue and abort the instance thread |
823 | // | 742 | // |
824 | instance.Stop(0, true); | 743 | instance.Stop(0, true); |
825 | ======= | ||
826 | // Clear the event queue and abort the instance thread | ||
827 | // | ||
828 | instance.ClearQueue(); | ||
829 | instance.Stop(0); | ||
830 | >>>>>>> avn/ubitvar | ||
831 | |||
832 | // Release events, timer, etc | ||
833 | // | ||
834 | instance.DestroyScriptInstance(); | ||
835 | 744 | ||
836 | // Unload scripts and app domains | 745 | // Release events, timer, etc |
837 | // Must be done explicitly because they have infinite | 746 | // |
838 | // lifetime | 747 | instance.DestroyScriptInstance(); |
839 | // | 748 | |
840 | // if (!m_SimulatorShuttingDown) | 749 | // Unload scripts and app domains. |
841 | { | 750 | // Must be done explicitly because they have infinite |
842 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 751 | // lifetime. |
843 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 752 | // However, don't bother to do this if the simulator is shutting |
753 | // down since it takes a long time with many scripts. | ||
754 | if (!m_SimulatorShuttingDown) | ||
844 | { | 755 | { |
845 | m_DomainScripts.Remove(instance.AppDomain); | 756 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
846 | UnloadAppDomain(instance.AppDomain); | 757 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
758 | { | ||
759 | m_DomainScripts.Remove(instance.AppDomain); | ||
760 | UnloadAppDomain(instance.AppDomain); | ||
761 | } | ||
847 | } | 762 | } |
848 | } | 763 | } |
849 | 764 | ||
850 | // m_Scripts.Clear(); | 765 | m_Scripts.Clear(); |
851 | // m_PrimObjects.Clear(); | 766 | m_PrimObjects.Clear(); |
852 | // m_Assemblies.Clear(); | 767 | m_Assemblies.Clear(); |
853 | // m_DomainScripts.Clear(); | 768 | m_DomainScripts.Clear(); |
854 | } | 769 | } |
855 | lockScriptsForRead(false); | ||
856 | lockScriptsForWrite(true); | ||
857 | m_Scripts.Clear(); | ||
858 | lockScriptsForWrite(false); | ||
859 | m_PrimObjects.Clear(); | ||
860 | m_Assemblies.Clear(); | ||
861 | m_DomainScripts.Clear(); | ||
862 | |||
863 | lock (m_ScriptEngines) | 770 | lock (m_ScriptEngines) |
864 | { | 771 | { |
865 | m_ScriptEngines.Remove(this); | 772 | m_ScriptEngines.Remove(this); |
@@ -928,7 +835,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
928 | 835 | ||
929 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 836 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
930 | 837 | ||
931 | <<<<<<< HEAD | ||
932 | lock (m_Scripts) | 838 | lock (m_Scripts) |
933 | { | 839 | { |
934 | foreach (IScriptInstance instance in m_Scripts.Values) | 840 | foreach (IScriptInstance instance in m_Scripts.Values) |
@@ -946,23 +852,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
946 | 852 | ||
947 | foreach (IScriptInstance i in instances) | 853 | foreach (IScriptInstance i in instances) |
948 | { | 854 | { |
949 | ======= | ||
950 | lockScriptsForRead(true); | ||
951 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
952 | instances.Add(instance); | ||
953 | lockScriptsForRead(false); | ||
954 | |||
955 | foreach (IScriptInstance i in instances) | ||
956 | { | ||
957 | string assembly = String.Empty; | ||
958 | |||
959 | |||
960 | if (!m_Assemblies.ContainsKey(i.AssetID)) | ||
961 | continue; | ||
962 | assembly = m_Assemblies[i.AssetID]; | ||
963 | |||
964 | |||
965 | >>>>>>> avn/ubitvar | ||
966 | try | 855 | try |
967 | { | 856 | { |
968 | i.SaveState(); | 857 | i.SaveState(); |
@@ -1393,79 +1282,58 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1393 | } | 1282 | } |
1394 | 1283 | ||
1395 | ScriptInstance instance = null; | 1284 | ScriptInstance instance = null; |
1396 | // Create the object record | 1285 | lock (m_Scripts) |
1397 | UUID appDomain = assetID; | ||
1398 | |||
1399 | |||
1400 | |||
1401 | lockScriptsForRead(true); | ||
1402 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
1403 | (m_Scripts[itemID].AssetID != assetID)) | ||
1404 | { | 1286 | { |
1405 | lockScriptsForRead(false); | 1287 | // Create the object record |
1406 | instance = new ScriptInstance(this, part, | 1288 | if ((!m_Scripts.ContainsKey(itemID)) || |
1407 | item, | 1289 | (m_Scripts[itemID].AssetID != assetID)) |
1408 | startParam, postOnRez, | 1290 | { |
1409 | m_MaxScriptQueue); | 1291 | UUID appDomain = assetID; |
1410 | 1292 | ||
1411 | if (part.ParentGroup.IsAttachment) | 1293 | if (part.ParentGroup.IsAttachment) |
1412 | appDomain = part.ParentGroup.RootPart.UUID; | 1294 | appDomain = part.ParentGroup.RootPart.UUID; |
1413 | 1295 | ||
1414 | if (!m_AppDomains.ContainsKey(appDomain)) | 1296 | if (!m_AppDomains.ContainsKey(appDomain)) |
1415 | { | ||
1416 | try | ||
1417 | { | 1297 | { |
1418 | AppDomainSetup appSetup = new AppDomainSetup(); | 1298 | try |
1419 | appSetup.PrivateBinPath = Path.Combine( | 1299 | { |
1420 | m_ScriptEnginesPath, | 1300 | AppDomainSetup appSetup = new AppDomainSetup(); |
1421 | m_Scene.RegionInfo.RegionID.ToString()); | 1301 | appSetup.PrivateBinPath = Path.Combine( |
1302 | m_ScriptEnginesPath, | ||
1303 | m_Scene.RegionInfo.RegionID.ToString()); | ||
1422 | 1304 | ||
1423 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 1305 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
1424 | Evidence evidence = new Evidence(baseEvidence); | 1306 | Evidence evidence = new Evidence(baseEvidence); |
1425 | 1307 | ||
1426 | AppDomain sandbox; | 1308 | AppDomain sandbox; |
1427 | if (m_AppDomainLoading) | 1309 | if (m_AppDomainLoading) |
1428 | { | ||
1429 | sandbox = AppDomain.CreateDomain( | ||
1430 | m_Scene.RegionInfo.RegionID.ToString(), | ||
1431 | evidence, appSetup); | ||
1432 | if (m_AppDomains.ContainsKey(appDomain)) | ||
1433 | { | 1310 | { |
1434 | m_AppDomains[appDomain].AssemblyResolve += | 1311 | sandbox = AppDomain.CreateDomain( |
1312 | m_Scene.RegionInfo.RegionID.ToString(), | ||
1313 | evidence, appSetup); | ||
1314 | sandbox.AssemblyResolve += | ||
1435 | new ResolveEventHandler( | 1315 | new ResolveEventHandler( |
1436 | AssemblyResolver.OnAssemblyResolve); | 1316 | AssemblyResolver.OnAssemblyResolve); |
1437 | if (m_DomainScripts.ContainsKey(appDomain)) | ||
1438 | { | ||
1439 | m_DomainScripts[appDomain].Add(itemID); | ||
1440 | } | ||
1441 | else | ||
1442 | { | ||
1443 | m_DomainScripts.Add(appDomain, new List<UUID>()); | ||
1444 | m_DomainScripts[appDomain].Add(itemID); | ||
1445 | } | ||
1446 | } | 1317 | } |
1447 | else | 1318 | else |
1448 | { | 1319 | { |
1449 | m_AppDomains.Add(appDomain, sandbox); | 1320 | sandbox = AppDomain.CurrentDomain; |
1450 | m_AppDomains[appDomain].AssemblyResolve += | ||
1451 | new ResolveEventHandler( | ||
1452 | AssemblyResolver.OnAssemblyResolve); | ||
1453 | if (m_DomainScripts.ContainsKey(appDomain)) | ||
1454 | { | ||
1455 | m_DomainScripts[appDomain].Add(itemID); | ||
1456 | } | ||
1457 | else | ||
1458 | { | ||
1459 | m_DomainScripts.Add(appDomain, new List<UUID>()); | ||
1460 | m_DomainScripts[appDomain].Add(itemID); | ||
1461 | } | ||
1462 | |||
1463 | } | 1321 | } |
1322 | |||
1323 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | ||
1324 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | ||
1325 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | ||
1326 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | ||
1327 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | ||
1328 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | ||
1329 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | ||
1330 | |||
1331 | m_AppDomains[appDomain] = sandbox; | ||
1464 | 1332 | ||
1333 | m_DomainScripts[appDomain] = new List<UUID>(); | ||
1465 | } | 1334 | } |
1466 | else | 1335 | catch (Exception e) |
1467 | { | 1336 | { |
1468 | <<<<<<< HEAD | ||
1469 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | 1337 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
1470 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | 1338 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
1471 | m_ScriptFailCount++; | 1339 | m_ScriptFailCount++; |
@@ -1474,12 +1342,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1474 | m_AddingAssemblies[assemblyPath]--; | 1342 | m_AddingAssemblies[assemblyPath]--; |
1475 | } | 1343 | } |
1476 | return false; | 1344 | return false; |
1477 | ======= | ||
1478 | sandbox = AppDomain.CurrentDomain; | ||
1479 | >>>>>>> avn/ubitvar | ||
1480 | } | 1345 | } |
1346 | } | ||
1347 | m_DomainScripts[appDomain].Add(itemID); | ||
1481 | 1348 | ||
1482 | <<<<<<< HEAD | ||
1483 | IScript scriptObj = null; | 1349 | IScript scriptObj = null; |
1484 | EventWaitHandle coopSleepHandle; | 1350 | EventWaitHandle coopSleepHandle; |
1485 | bool coopTerminationForThisScript; | 1351 | bool coopTerminationForThisScript; |
@@ -1611,52 +1477,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1611 | scriptObj, coopSleepHandle, assemblyPath, | 1477 | scriptObj, coopSleepHandle, assemblyPath, |
1612 | Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) | 1478 | Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) |
1613 | return false; | 1479 | return false; |
1614 | ======= | ||
1615 | // if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) | ||
1616 | // return false; | ||
1617 | >>>>>>> avn/ubitvar | ||
1618 | 1480 | ||
1619 | m_AppDomains[appDomain] = sandbox; | 1481 | // if (DebugLevel >= 1) |
1482 | // m_log.DebugFormat( | ||
1483 | // "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | ||
1484 | // part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | ||
1485 | // part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
1620 | 1486 | ||
1621 | m_DomainScripts[appDomain] = new List<UUID>(); | 1487 | if (presence != null) |
1622 | } | ||
1623 | catch (Exception e) | ||
1624 | { | 1488 | { |
1625 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | 1489 | ShowScriptSaveResponse(item.OwnerID, |
1626 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | 1490 | assetID, "Compile successful", true); |
1627 | m_ScriptFailCount++; | ||
1628 | lock (m_AddingAssemblies) | ||
1629 | { | ||
1630 | m_AddingAssemblies[assembly]--; | ||
1631 | } | ||
1632 | return false; | ||
1633 | } | 1491 | } |
1634 | } | ||
1635 | 1492 | ||
1493 | instance.AppDomain = appDomain; | ||
1494 | instance.LineMap = linemap; | ||
1636 | 1495 | ||
1637 | if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) | 1496 | m_Scripts[itemID] = instance; |
1638 | return false; | ||
1639 | // m_log.DebugFormat( | ||
1640 | // "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", | ||
1641 | // part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | ||
1642 | // part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
1643 | |||
1644 | if (presence != null) | ||
1645 | { | ||
1646 | ShowScriptSaveResponse(item.OwnerID, | ||
1647 | assetID, "Compile successful", true); | ||
1648 | } | 1497 | } |
1649 | |||
1650 | instance.AppDomain = appDomain; | ||
1651 | instance.LineMap = linemap; | ||
1652 | lockScriptsForWrite(true); | ||
1653 | m_Scripts[itemID] = instance; | ||
1654 | lockScriptsForWrite(false); | ||
1655 | } | ||
1656 | else | ||
1657 | { | ||
1658 | lockScriptsForRead(false); | ||
1659 | } | 1498 | } |
1499 | |||
1660 | lock (m_PrimObjects) | 1500 | lock (m_PrimObjects) |
1661 | { | 1501 | { |
1662 | if (!m_PrimObjects.ContainsKey(localID)) | 1502 | if (!m_PrimObjects.ContainsKey(localID)) |
@@ -1674,7 +1514,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1674 | m_AddingAssemblies[assemblyPath]--; | 1514 | m_AddingAssemblies[assemblyPath]--; |
1675 | } | 1515 | } |
1676 | 1516 | ||
1677 | if (instance!=null) | 1517 | if (instance != null) |
1678 | instance.Init(); | 1518 | instance.Init(); |
1679 | 1519 | ||
1680 | bool runIt; | 1520 | bool runIt; |
@@ -1697,28 +1537,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1697 | m_CompileDict.Remove(itemID); | 1537 | m_CompileDict.Remove(itemID); |
1698 | } | 1538 | } |
1699 | 1539 | ||
1700 | lockScriptsForRead(true); | 1540 | IScriptInstance instance = null; |
1701 | // Do we even have it? | ||
1702 | if (!m_Scripts.ContainsKey(itemID)) | ||
1703 | { | ||
1704 | lockScriptsForRead(false); | ||
1705 | return; | ||
1706 | } | ||
1707 | 1541 | ||
1708 | <<<<<<< HEAD | 1542 | lock (m_Scripts) |
1709 | instance.Stop(m_WaitForEventCompletionOnScriptStop, true); | 1543 | { |
1710 | ======= | 1544 | // Do we even have it? |
1711 | IScriptInstance instance=m_Scripts[itemID]; | 1545 | if (!m_Scripts.ContainsKey(itemID)) |
1712 | lockScriptsForRead(false); | 1546 | return; |
1713 | lockScriptsForWrite(true); | ||
1714 | m_Scripts.Remove(itemID); | ||
1715 | lockScriptsForWrite(false); | ||
1716 | instance.ClearQueue(); | ||
1717 | 1547 | ||
1718 | instance.Stop(m_WaitForEventCompletionOnScriptStop); | 1548 | instance = m_Scripts[itemID]; |
1549 | m_Scripts.Remove(itemID); | ||
1550 | } | ||
1719 | 1551 | ||
1720 | // bool objectRemoved = false; | 1552 | instance.Stop(m_WaitForEventCompletionOnScriptStop, true); |
1721 | >>>>>>> avn/ubitvar | ||
1722 | 1553 | ||
1723 | lock (m_PrimObjects) | 1554 | lock (m_PrimObjects) |
1724 | { | 1555 | { |
@@ -1740,26 +1571,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1740 | 1571 | ||
1741 | instance.DestroyScriptInstance(); | 1572 | instance.DestroyScriptInstance(); |
1742 | 1573 | ||
1743 | if (m_DomainScripts.ContainsKey(instance.AppDomain)) | 1574 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
1575 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
1744 | { | 1576 | { |
1745 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 1577 | m_DomainScripts.Remove(instance.AppDomain); |
1746 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 1578 | UnloadAppDomain(instance.AppDomain); |
1747 | { | ||
1748 | m_DomainScripts.Remove(instance.AppDomain); | ||
1749 | UnloadAppDomain(instance.AppDomain); | ||
1750 | } | ||
1751 | } | 1579 | } |
1752 | 1580 | ||
1753 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 1581 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
1754 | if (handlerObjectRemoved != null) | 1582 | if (handlerObjectRemoved != null) |
1755 | { | 1583 | handlerObjectRemoved(instance.ObjectID); |
1756 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
1757 | if (part != null) | ||
1758 | handlerObjectRemoved(part.UUID); | ||
1759 | } | ||
1760 | 1584 | ||
1761 | CleanAssemblies(); | ||
1762 | |||
1763 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 1585 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
1764 | if (handlerScriptRemoved != null) | 1586 | if (handlerScriptRemoved != null) |
1765 | handlerScriptRemoved(itemID); | 1587 | handlerScriptRemoved(itemID); |
@@ -2020,14 +1842,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
2020 | private IScriptInstance GetInstance(UUID itemID) | 1842 | private IScriptInstance GetInstance(UUID itemID) |
2021 | { | 1843 | { |
2022 | IScriptInstance instance; | 1844 | IScriptInstance instance; |
2023 | lockScriptsForRead(true); | 1845 | lock (m_Scripts) |
2024 | if (!m_Scripts.ContainsKey(itemID)) | ||
2025 | { | 1846 | { |
2026 | lockScriptsForRead(false); | 1847 | if (!m_Scripts.ContainsKey(itemID)) |
2027 | return null; | 1848 | return null; |
1849 | instance = m_Scripts[itemID]; | ||
2028 | } | 1850 | } |
2029 | instance = m_Scripts[itemID]; | ||
2030 | lockScriptsForRead(false); | ||
2031 | return instance; | 1851 | return instance; |
2032 | } | 1852 | } |
2033 | 1853 | ||
@@ -2049,7 +1869,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
2049 | return instance != null && instance.Running; | 1869 | return instance != null && instance.Running; |
2050 | } | 1870 | } |
2051 | 1871 | ||
2052 | [DebuggerNonUserCode] | ||
2053 | public void ApiResetScript(UUID itemID) | 1872 | public void ApiResetScript(UUID itemID) |
2054 | { | 1873 | { |
2055 | IScriptInstance instance = GetInstance(itemID); | 1874 | IScriptInstance instance = GetInstance(itemID); |
@@ -2134,7 +1953,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
2134 | return instance != null ? instance.GetDetectID(idx) : UUID.Zero; | 1953 | return instance != null ? instance.GetDetectID(idx) : UUID.Zero; |
2135 | } | 1954 | } |
2136 | 1955 | ||
2137 | [DebuggerNonUserCode] | ||
2138 | public void SetState(UUID itemID, string newState) | 1956 | public void SetState(UUID itemID, string newState) |
2139 | { | 1957 | { |
2140 | IScriptInstance instance = GetInstance(itemID); | 1958 | IScriptInstance instance = GetInstance(itemID); |
@@ -2155,10 +1973,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
2155 | 1973 | ||
2156 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 1974 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
2157 | 1975 | ||
2158 | lockScriptsForRead(true); | 1976 | lock (m_Scripts) |
2159 | foreach (IScriptInstance instance in m_Scripts.Values) | 1977 | { |
1978 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
2160 | instances.Add(instance); | 1979 | instances.Add(instance); |
2161 | lockScriptsForRead(false); | 1980 | } |
2162 | 1981 | ||
2163 | foreach (IScriptInstance i in instances) | 1982 | foreach (IScriptInstance i in instances) |
2164 | { | 1983 | { |