diff options
author | Oren Hurvitz | 2012-12-14 16:17:07 +0200 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-02 22:48:25 +0000 |
commit | 5097ba81d4aaddd14b9420a4b2298c00c60aa1d4 (patch) | |
tree | 2f5efec3feabc2d4be8d78b9bfe7be2ae8cfbfbd /OpenSim/Data | |
parent | Fix indenting on ConsoleDisplayTable, align indenting on "show animations" co... (diff) | |
download | opensim-SC_OLD-5097ba81d4aaddd14b9420a4b2298c00c60aa1d4.zip opensim-SC_OLD-5097ba81d4aaddd14b9420a4b2298c00c60aa1d4.tar.gz opensim-SC_OLD-5097ba81d4aaddd14b9420a4b2298c00c60aa1d4.tar.bz2 opensim-SC_OLD-5097ba81d4aaddd14b9420a4b2298c00c60aa1d4.tar.xz |
Added locking in NullRegionData.
This prevents errors when one thread iterates over the regions (e.g., from RegenerateMaptileAndReregister()) while another thread is adding a region.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/Null/NullRegionData.cs | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index b4d701a..f707d98 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs | |||
@@ -113,11 +113,14 @@ namespace OpenSim.Data.Null | |||
113 | // Find region data | 113 | // Find region data |
114 | List<RegionData> ret = new List<RegionData>(); | 114 | List<RegionData> ret = new List<RegionData>(); |
115 | 115 | ||
116 | foreach (RegionData r in m_regionData.Values) | 116 | lock (m_regionData) |
117 | { | 117 | { |
118 | // m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower()); | 118 | foreach (RegionData r in m_regionData.Values) |
119 | { | ||
120 | // m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower()); | ||
119 | if (queryMatch(r.RegionName.ToLower())) | 121 | if (queryMatch(r.RegionName.ToLower())) |
120 | ret.Add(r); | 122 | ret.Add(r); |
123 | } | ||
121 | } | 124 | } |
122 | 125 | ||
123 | if (ret.Count > 0) | 126 | if (ret.Count > 0) |
@@ -133,10 +136,13 @@ namespace OpenSim.Data.Null | |||
133 | 136 | ||
134 | List<RegionData> ret = new List<RegionData>(); | 137 | List<RegionData> ret = new List<RegionData>(); |
135 | 138 | ||
136 | foreach (RegionData r in m_regionData.Values) | 139 | lock (m_regionData) |
137 | { | 140 | { |
138 | if (r.posX == posX && r.posY == posY) | 141 | foreach (RegionData r in m_regionData.Values) |
139 | ret.Add(r); | 142 | { |
143 | if (r.posX == posX && r.posY == posY) | ||
144 | ret.Add(r); | ||
145 | } | ||
140 | } | 146 | } |
141 | 147 | ||
142 | if (ret.Count > 0) | 148 | if (ret.Count > 0) |
@@ -150,8 +156,11 @@ namespace OpenSim.Data.Null | |||
150 | if (m_useStaticInstance && Instance != this) | 156 | if (m_useStaticInstance && Instance != this) |
151 | return Instance.Get(regionID, scopeID); | 157 | return Instance.Get(regionID, scopeID); |
152 | 158 | ||
153 | if (m_regionData.ContainsKey(regionID)) | 159 | lock (m_regionData) |
154 | return m_regionData[regionID]; | 160 | { |
161 | if (m_regionData.ContainsKey(regionID)) | ||
162 | return m_regionData[regionID]; | ||
163 | } | ||
155 | 164 | ||
156 | return null; | 165 | return null; |
157 | } | 166 | } |
@@ -163,10 +172,13 @@ namespace OpenSim.Data.Null | |||
163 | 172 | ||
164 | List<RegionData> ret = new List<RegionData>(); | 173 | List<RegionData> ret = new List<RegionData>(); |
165 | 174 | ||
166 | foreach (RegionData r in m_regionData.Values) | 175 | lock (m_regionData) |
167 | { | 176 | { |
168 | if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY) | 177 | foreach (RegionData r in m_regionData.Values) |
169 | ret.Add(r); | 178 | { |
179 | if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY) | ||
180 | ret.Add(r); | ||
181 | } | ||
170 | } | 182 | } |
171 | 183 | ||
172 | return ret; | 184 | return ret; |
@@ -180,7 +192,10 @@ namespace OpenSim.Data.Null | |||
180 | // m_log.DebugFormat( | 192 | // m_log.DebugFormat( |
181 | // "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID); | 193 | // "[NULL REGION DATA]: Storing region {0} {1}, scope {2}", data.RegionName, data.RegionID, data.ScopeID); |
182 | 194 | ||
183 | m_regionData[data.RegionID] = data; | 195 | lock (m_regionData) |
196 | { | ||
197 | m_regionData[data.RegionID] = data; | ||
198 | } | ||
184 | 199 | ||
185 | return true; | 200 | return true; |
186 | } | 201 | } |
@@ -190,10 +205,13 @@ namespace OpenSim.Data.Null | |||
190 | if (m_useStaticInstance && Instance != this) | 205 | if (m_useStaticInstance && Instance != this) |
191 | return Instance.SetDataItem(regionID, item, value); | 206 | return Instance.SetDataItem(regionID, item, value); |
192 | 207 | ||
193 | if (!m_regionData.ContainsKey(regionID)) | 208 | lock (m_regionData) |
194 | return false; | 209 | { |
210 | if (!m_regionData.ContainsKey(regionID)) | ||
211 | return false; | ||
195 | 212 | ||
196 | m_regionData[regionID].Data[item] = value; | 213 | m_regionData[regionID].Data[item] = value; |
214 | } | ||
197 | 215 | ||
198 | return true; | 216 | return true; |
199 | } | 217 | } |
@@ -205,10 +223,13 @@ namespace OpenSim.Data.Null | |||
205 | 223 | ||
206 | // m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID); | 224 | // m_log.DebugFormat("[NULL REGION DATA]: Deleting region {0}", regionID); |
207 | 225 | ||
208 | if (!m_regionData.ContainsKey(regionID)) | 226 | lock (m_regionData) |
209 | return false; | 227 | { |
228 | if (!m_regionData.ContainsKey(regionID)) | ||
229 | return false; | ||
210 | 230 | ||
211 | m_regionData.Remove(regionID); | 231 | m_regionData.Remove(regionID); |
232 | } | ||
212 | 233 | ||
213 | return true; | 234 | return true; |
214 | } | 235 | } |
@@ -238,10 +259,13 @@ namespace OpenSim.Data.Null | |||
238 | 259 | ||
239 | List<RegionData> ret = new List<RegionData>(); | 260 | List<RegionData> ret = new List<RegionData>(); |
240 | 261 | ||
241 | foreach (RegionData r in m_regionData.Values) | 262 | lock (m_regionData) |
242 | { | 263 | { |
243 | if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0) | 264 | foreach (RegionData r in m_regionData.Values) |
244 | ret.Add(r); | 265 | { |
266 | if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0) | ||
267 | ret.Add(r); | ||
268 | } | ||
245 | } | 269 | } |
246 | 270 | ||
247 | return ret; | 271 | return ret; |