diff options
author | Justin Clark-Casey (justincc) | 2012-08-14 21:44:06 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-08-14 21:44:06 +0100 |
commit | c42fe6c159d49535888937c3f219e028eb755efa (patch) | |
tree | 70f6932fe9ed33ec4ac09fe1deb5e34a712c7b03 /OpenSim/Region/OptionalModules/World | |
parent | Perform ownership transfer and permission propagation as well as needed (diff) | |
download | opensim-SC-c42fe6c159d49535888937c3f219e028eb755efa.zip opensim-SC-c42fe6c159d49535888937c3f219e028eb755efa.tar.gz opensim-SC-c42fe6c159d49535888937c3f219e028eb755efa.tar.bz2 opensim-SC-c42fe6c159d49535888937c3f219e028eb755efa.tar.xz |
Prevent race conditions when one thread removes an NPC SP before another thread has retreived it after checking whether the NPC exists.
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 1e85fb4..3f25bcf 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -176,16 +176,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
176 | if (m_avatars.ContainsKey(agentID)) | 176 | if (m_avatars.ContainsKey(agentID)) |
177 | { | 177 | { |
178 | ScenePresence sp; | 178 | ScenePresence sp; |
179 | scene.TryGetScenePresence(agentID, out sp); | 179 | if (scene.TryGetScenePresence(agentID, out sp)) |
180 | 180 | { | |
181 | m_log.DebugFormat( | 181 | m_log.DebugFormat( |
182 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", | 182 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
183 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); | 183 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); |
184 | 184 | ||
185 | sp.MoveToTarget(pos, noFly, landAtTarget); | 185 | sp.MoveToTarget(pos, noFly, landAtTarget); |
186 | sp.SetAlwaysRun = running; | 186 | sp.SetAlwaysRun = running; |
187 | 187 | ||
188 | return true; | 188 | return true; |
189 | } | ||
189 | } | 190 | } |
190 | } | 191 | } |
191 | 192 | ||
@@ -199,12 +200,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
199 | if (m_avatars.ContainsKey(agentID)) | 200 | if (m_avatars.ContainsKey(agentID)) |
200 | { | 201 | { |
201 | ScenePresence sp; | 202 | ScenePresence sp; |
202 | scene.TryGetScenePresence(agentID, out sp); | 203 | if (scene.TryGetScenePresence(agentID, out sp)) |
203 | 204 | { | |
204 | sp.Velocity = Vector3.Zero; | 205 | sp.Velocity = Vector3.Zero; |
205 | sp.ResetMoveToTarget(); | 206 | sp.ResetMoveToTarget(); |
206 | 207 | ||
207 | return true; | 208 | return true; |
209 | } | ||
208 | } | 210 | } |
209 | } | 211 | } |
210 | 212 | ||
@@ -222,9 +224,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
222 | { | 224 | { |
223 | if (m_avatars.ContainsKey(agentID)) | 225 | if (m_avatars.ContainsKey(agentID)) |
224 | { | 226 | { |
225 | ScenePresence sp; | ||
226 | scene.TryGetScenePresence(agentID, out sp); | ||
227 | |||
228 | m_avatars[agentID].Say(channel, text); | 227 | m_avatars[agentID].Say(channel, text); |
229 | 228 | ||
230 | return true; | 229 | return true; |
@@ -240,9 +239,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
240 | { | 239 | { |
241 | if (m_avatars.ContainsKey(agentID)) | 240 | if (m_avatars.ContainsKey(agentID)) |
242 | { | 241 | { |
243 | ScenePresence sp; | ||
244 | scene.TryGetScenePresence(agentID, out sp); | ||
245 | |||
246 | m_avatars[agentID].Shout(channel, text); | 242 | m_avatars[agentID].Shout(channel, text); |
247 | 243 | ||
248 | return true; | 244 | return true; |
@@ -259,11 +255,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
259 | if (m_avatars.ContainsKey(agentID)) | 255 | if (m_avatars.ContainsKey(agentID)) |
260 | { | 256 | { |
261 | ScenePresence sp; | 257 | ScenePresence sp; |
262 | scene.TryGetScenePresence(agentID, out sp); | 258 | if (scene.TryGetScenePresence(agentID, out sp)) |
263 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); | 259 | { |
264 | // sp.HandleAgentSit(m_avatars[agentID], agentID); | 260 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); |
265 | 261 | // sp.HandleAgentSit(m_avatars[agentID], agentID); | |
266 | return true; | 262 | |
263 | return true; | ||
264 | } | ||
267 | } | 265 | } |
268 | } | 266 | } |
269 | 267 | ||
@@ -276,9 +274,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
276 | { | 274 | { |
277 | if (m_avatars.ContainsKey(agentID)) | 275 | if (m_avatars.ContainsKey(agentID)) |
278 | { | 276 | { |
279 | ScenePresence sp; | ||
280 | scene.TryGetScenePresence(agentID, out sp); | ||
281 | |||
282 | m_avatars[agentID].Whisper(channel, text); | 277 | m_avatars[agentID].Whisper(channel, text); |
283 | 278 | ||
284 | return true; | 279 | return true; |
@@ -295,10 +290,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
295 | if (m_avatars.ContainsKey(agentID)) | 290 | if (m_avatars.ContainsKey(agentID)) |
296 | { | 291 | { |
297 | ScenePresence sp; | 292 | ScenePresence sp; |
298 | scene.TryGetScenePresence(agentID, out sp); | 293 | if (scene.TryGetScenePresence(agentID, out sp)) |
299 | sp.StandUp(); | 294 | { |
295 | sp.StandUp(); | ||
300 | 296 | ||
301 | return true; | 297 | return true; |
298 | } | ||
302 | } | 299 | } |
303 | } | 300 | } |
304 | 301 | ||
@@ -311,6 +308,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
311 | { | 308 | { |
312 | if (m_avatars.ContainsKey(agentID)) | 309 | if (m_avatars.ContainsKey(agentID)) |
313 | return m_avatars[agentID].Touch(objectID); | 310 | return m_avatars[agentID].Touch(objectID); |
311 | |||
314 | return false; | 312 | return false; |
315 | } | 313 | } |
316 | } | 314 | } |
@@ -321,9 +319,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
321 | { | 319 | { |
322 | NPCAvatar av; | 320 | NPCAvatar av; |
323 | if (m_avatars.TryGetValue(agentID, out av)) | 321 | if (m_avatars.TryGetValue(agentID, out av)) |
324 | { | ||
325 | return av.OwnerID; | 322 | return av.OwnerID; |
326 | } | ||
327 | } | 323 | } |
328 | 324 | ||
329 | return UUID.Zero; | 325 | return UUID.Zero; |