From b3d152f3ba5cb07c005b0163c752f2c0f97c0034 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 10 Feb 2012 21:26:05 +0000 Subject: Fix an npc delete race condition with LSL sensors where an initial presence check could succeed but then the npc removed before the subequent npc check. The resulting null would cause an exception. We now check for null before looking at SenseAsAgent. Hopefully fixes http://opensimulator.org/mantis/view.php?id=5872 --- .../Api/Implementation/Plugins/SensorRepeat.cs | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 3e0e452..850f50b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -445,17 +445,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins Vector3 toRegionPos; double dis; - Action senseEntity = new Action(delegate(ScenePresence presence) + Action senseEntity = new Action(presence => { - if ((ts.type & NPC) == 0 - && presence.PresenceType == PresenceType.Npc - && !npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent) - return; + if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) + { + INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); + if (npcData == null || !npcData.SenseAsAgent) + return; + } - if ((ts.type & AGENT) == 0 - && (presence.PresenceType == PresenceType.User - || npcModule.GetNPC(presence.UUID, presence.Scene).SenseAsAgent)) - return; + if ((ts.type & AGENT) == 0) + { + if (presence.PresenceType == PresenceType.User) + { + return; + } + else + { + INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); + if (npcData != null && npcData.SenseAsAgent) + return; + } + } if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) return; -- cgit v1.1