diff options
author | Justin Clark-Casey (justincc) | 2013-03-13 23:42:14 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-13 23:42:14 +0000 |
commit | 43220afda2a69e7849c2ab9f98dcbd61a3da218b (patch) | |
tree | 20f9aca83a7284ffca4c7f1788f42395849e9aac /OpenSim/Region/CoreModules | |
parent | Remove unnecessary instation of DOMap() in SOP from commit 5c53660 since this... (diff) | |
download | opensim-SC_OLD-43220afda2a69e7849c2ab9f98dcbd61a3da218b.zip opensim-SC_OLD-43220afda2a69e7849c2ab9f98dcbd61a3da218b.tar.gz opensim-SC_OLD-43220afda2a69e7849c2ab9f98dcbd61a3da218b.tar.bz2 opensim-SC_OLD-43220afda2a69e7849c2ab9f98dcbd61a3da218b.tar.xz |
Improve DAExampleModule to show current necessary locking to avoid race conditions with a serialization thread.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs index 37131b9..f874495 100644 --- a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs | |||
@@ -85,19 +85,27 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule | |||
85 | { | 85 | { |
86 | OSDMap attrs = null; | 86 | OSDMap attrs = null; |
87 | SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); | 87 | SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); |
88 | |||
89 | if (sop == null) | ||
90 | return true; | ||
91 | |||
88 | if (!sop.DynAttrs.TryGetValue(Name, out attrs)) | 92 | if (!sop.DynAttrs.TryGetValue(Name, out attrs)) |
89 | attrs = new OSDMap(); | 93 | attrs = new OSDMap(); |
90 | 94 | ||
91 | OSDInteger newValue; | 95 | OSDInteger newValue; |
92 | |||
93 | if (!attrs.ContainsKey("moves")) | ||
94 | newValue = new OSDInteger(1); | ||
95 | else | ||
96 | newValue = new OSDInteger(((OSDInteger)attrs["moves"]).AsInteger() + 1); | ||
97 | |||
98 | attrs["moves"] = newValue; | ||
99 | 96 | ||
100 | sop.DynAttrs[Name] = attrs; | 97 | // We have to lock on the entire dynamic attributes map to avoid race conditions with serialization code. |
98 | lock (sop.DynAttrs) | ||
99 | { | ||
100 | if (!attrs.ContainsKey("moves")) | ||
101 | newValue = new OSDInteger(1); | ||
102 | else | ||
103 | newValue = new OSDInteger(attrs["moves"].AsInteger() + 1); | ||
104 | |||
105 | attrs["moves"] = newValue; | ||
106 | |||
107 | sop.DynAttrs[Name] = attrs; | ||
108 | } | ||
101 | 109 | ||
102 | m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); | 110 | m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); |
103 | 111 | ||