diff options
author | Justin Clark-Casey (justincc) | 2010-07-20 21:57:03 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-20 21:57:03 +0100 |
commit | 79d33418f0950a75d64d2779bf7eeacc97ac3e31 (patch) | |
tree | ce0f3741579e68845cfe46ffed7a7bf4ebfc7225 /OpenSim/Region/ScriptEngine/XEngine | |
parent | Add region name on the end of script startup debug messages (diff) | |
parent | Relaxed the ultra-conservative lock on m_items. Needs testing under linux and... (diff) | |
download | opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.zip opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.tar.gz opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.tar.bz2 opensim-SC_OLD-79d33418f0950a75d64d2779bf7eeacc97ac3e31.tar.xz |
Merge branch '0.7-post-fixes' of ssh://opensimulator.org/var/git/opensim into 0.7-post-fixes
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 130 |
1 files changed, 69 insertions, 61 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index bc5df11..cc9e58c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
701 | } | 701 | } |
702 | } | 702 | } |
703 | 703 | ||
704 | ScriptInstance instance = null; | ||
704 | lock (m_Scripts) | 705 | lock (m_Scripts) |
705 | { | 706 | { |
706 | ScriptInstance instance = null; | ||
707 | // Create the object record | 707 | // Create the object record |
708 | 708 | ||
709 | if ((!m_Scripts.ContainsKey(itemID)) || | 709 | if ((!m_Scripts.ContainsKey(itemID)) || |
@@ -786,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
786 | 786 | ||
787 | m_Scripts[itemID] = instance; | 787 | m_Scripts[itemID] = instance; |
788 | } | 788 | } |
789 | } | ||
789 | 790 | ||
790 | lock (m_PrimObjects) | 791 | lock (m_PrimObjects) |
791 | { | 792 | { |
792 | if (!m_PrimObjects.ContainsKey(localID)) | 793 | if (!m_PrimObjects.ContainsKey(localID)) |
793 | m_PrimObjects[localID] = new List<UUID>(); | 794 | m_PrimObjects[localID] = new List<UUID>(); |
794 | |||
795 | if (!m_PrimObjects[localID].Contains(itemID)) | ||
796 | m_PrimObjects[localID].Add(itemID); | ||
797 | 795 | ||
798 | } | 796 | if (!m_PrimObjects[localID].Contains(itemID)) |
797 | m_PrimObjects[localID].Add(itemID); | ||
799 | 798 | ||
800 | if (!m_Assemblies.ContainsKey(assetID)) | 799 | } |
801 | m_Assemblies[assetID] = assembly; | ||
802 | 800 | ||
803 | lock (m_AddingAssemblies) | 801 | if (!m_Assemblies.ContainsKey(assetID)) |
804 | { | 802 | m_Assemblies[assetID] = assembly; |
805 | m_AddingAssemblies[assembly]--; | ||
806 | } | ||
807 | 803 | ||
808 | if (instance!=null) | 804 | lock (m_AddingAssemblies) |
809 | instance.Init(); | 805 | { |
806 | m_AddingAssemblies[assembly]--; | ||
810 | } | 807 | } |
808 | |||
809 | if (instance != null) | ||
810 | instance.Init(); | ||
811 | |||
811 | return true; | 812 | return true; |
812 | } | 813 | } |
813 | 814 | ||
@@ -820,60 +821,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
820 | m_CompileDict.Remove(itemID); | 821 | m_CompileDict.Remove(itemID); |
821 | } | 822 | } |
822 | 823 | ||
824 | IScriptInstance instance = null; | ||
825 | |||
823 | lock (m_Scripts) | 826 | lock (m_Scripts) |
824 | { | 827 | { |
825 | // Do we even have it? | 828 | // Do we even have it? |
826 | if (!m_Scripts.ContainsKey(itemID)) | 829 | if (!m_Scripts.ContainsKey(itemID)) |
827 | return; | 830 | return; |
828 | 831 | ||
829 | IScriptInstance instance=m_Scripts[itemID]; | 832 | instance=m_Scripts[itemID]; |
830 | m_Scripts.Remove(itemID); | 833 | m_Scripts.Remove(itemID); |
834 | } | ||
831 | 835 | ||
832 | instance.ClearQueue(); | 836 | instance.ClearQueue(); |
833 | instance.Stop(0); | 837 | instance.Stop(0); |
834 | |||
835 | // bool objectRemoved = false; | 838 | // bool objectRemoved = false; |
836 | 839 | ||
837 | lock (m_PrimObjects) | 840 | lock (m_PrimObjects) |
841 | { | ||
842 | // Remove the script from it's prim | ||
843 | if (m_PrimObjects.ContainsKey(localID)) | ||
838 | { | 844 | { |
839 | // Remove the script from it's prim | 845 | // Remove inventory item record |
840 | if (m_PrimObjects.ContainsKey(localID)) | 846 | if (m_PrimObjects[localID].Contains(itemID)) |
841 | { | 847 | m_PrimObjects[localID].Remove(itemID); |
842 | // Remove inventory item record | ||
843 | if (m_PrimObjects[localID].Contains(itemID)) | ||
844 | m_PrimObjects[localID].Remove(itemID); | ||
845 | 848 | ||
846 | // If there are no more scripts, remove prim | 849 | // If there are no more scripts, remove prim |
847 | if (m_PrimObjects[localID].Count == 0) | 850 | if (m_PrimObjects[localID].Count == 0) |
848 | { | 851 | { |
849 | m_PrimObjects.Remove(localID); | 852 | m_PrimObjects.Remove(localID); |
850 | // objectRemoved = true; | 853 | // objectRemoved = true; |
851 | } | ||
852 | } | 854 | } |
853 | } | 855 | } |
856 | } | ||
854 | 857 | ||
855 | instance.RemoveState(); | 858 | instance.RemoveState(); |
856 | instance.DestroyScriptInstance(); | 859 | instance.DestroyScriptInstance(); |
857 | |||
858 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | ||
859 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
860 | { | ||
861 | m_DomainScripts.Remove(instance.AppDomain); | ||
862 | UnloadAppDomain(instance.AppDomain); | ||
863 | } | ||
864 | 860 | ||
865 | instance = null; | 861 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
862 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
863 | { | ||
864 | m_DomainScripts.Remove(instance.AppDomain); | ||
865 | UnloadAppDomain(instance.AppDomain); | ||
866 | } | ||
866 | 867 | ||
867 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 868 | instance = null; |
868 | if (handlerObjectRemoved != null) | ||
869 | { | ||
870 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
871 | handlerObjectRemoved(part.UUID); | ||
872 | } | ||
873 | 869 | ||
874 | CleanAssemblies(); | 870 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
871 | if (handlerObjectRemoved != null) | ||
872 | { | ||
873 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
874 | handlerObjectRemoved(part.UUID); | ||
875 | } | 875 | } |
876 | 876 | ||
877 | |||
877 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 878 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
878 | if (handlerScriptRemoved != null) | 879 | if (handlerScriptRemoved != null) |
879 | handlerScriptRemoved(itemID); | 880 | handlerScriptRemoved(itemID); |
@@ -1007,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1007 | public bool PostObjectEvent(uint localID, EventParams p) | 1008 | public bool PostObjectEvent(uint localID, EventParams p) |
1008 | { | 1009 | { |
1009 | bool result = false; | 1010 | bool result = false; |
1010 | 1011 | List<UUID> uuids = null; | |
1012 | |||
1011 | lock (m_PrimObjects) | 1013 | lock (m_PrimObjects) |
1012 | { | 1014 | { |
1013 | if (!m_PrimObjects.ContainsKey(localID)) | 1015 | if (!m_PrimObjects.ContainsKey(localID)) |
1014 | return false; | 1016 | return false; |
1015 | 1017 | ||
1016 | 1018 | uuids = m_PrimObjects[localID]; | |
1017 | foreach (UUID itemID in m_PrimObjects[localID]) | 1019 | } |
1020 | |||
1021 | foreach (UUID itemID in uuids) | ||
1022 | { | ||
1023 | IScriptInstance instance = null; | ||
1024 | try | ||
1018 | { | 1025 | { |
1019 | if (m_Scripts.ContainsKey(itemID)) | 1026 | if (m_Scripts.ContainsKey(itemID)) |
1020 | { | 1027 | instance = m_Scripts[itemID]; |
1021 | IScriptInstance instance = m_Scripts[itemID]; | 1028 | } |
1022 | if (instance != null) | 1029 | catch { /* ignore race conditions */ } |
1023 | { | 1030 | |
1024 | instance.PostEvent(p); | 1031 | if (instance != null) |
1025 | result = true; | 1032 | { |
1026 | } | 1033 | instance.PostEvent(p); |
1027 | } | 1034 | result = true; |
1028 | } | 1035 | } |
1029 | } | 1036 | } |
1037 | |||
1030 | return result; | 1038 | return result; |
1031 | } | 1039 | } |
1032 | 1040 | ||