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/ScriptEngine/Shared/Api | |
parent | Perform ownership transfer and permission propagation as well as needed (diff) | |
download | opensim-SC_OLD-c42fe6c159d49535888937c3f219e028eb755efa.zip opensim-SC_OLD-c42fe6c159d49535888937c3f219e028eb755efa.tar.gz opensim-SC_OLD-c42fe6c159d49535888937c3f219e028eb755efa.tar.bz2 opensim-SC_OLD-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/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index bcd1a6f..859ee93 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2434,8 +2434,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2434 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) | 2434 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2435 | return new LSL_Vector(0, 0, 0); | 2435 | return new LSL_Vector(0, 0, 0); |
2436 | 2436 | ||
2437 | Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; | 2437 | ScenePresence sp = World.GetScenePresence(npcId); |
2438 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | 2438 | |
2439 | if (sp != null) | ||
2440 | { | ||
2441 | Vector3 pos = sp.AbsolutePosition; | ||
2442 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2443 | } | ||
2439 | } | 2444 | } |
2440 | 2445 | ||
2441 | return new LSL_Vector(0, 0, 0); | 2446 | return new LSL_Vector(0, 0, 0); |
@@ -2503,9 +2508,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2503 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2508 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); |
2504 | 2509 | ||
2505 | ScenePresence sp = World.GetScenePresence(npcId); | 2510 | ScenePresence sp = World.GetScenePresence(npcId); |
2506 | Quaternion rot = sp.Rotation; | ||
2507 | 2511 | ||
2508 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | 2512 | if (sp != null) |
2513 | { | ||
2514 | Quaternion rot = sp.Rotation; | ||
2515 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2516 | } | ||
2509 | } | 2517 | } |
2510 | 2518 | ||
2511 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2519 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); |
@@ -2527,7 +2535,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2527 | return; | 2535 | return; |
2528 | 2536 | ||
2529 | ScenePresence sp = World.GetScenePresence(npcId); | 2537 | ScenePresence sp = World.GetScenePresence(npcId); |
2530 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | 2538 | |
2539 | if (sp != null) | ||
2540 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | ||
2531 | } | 2541 | } |
2532 | } | 2542 | } |
2533 | 2543 | ||
@@ -2689,6 +2699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2689 | { | 2699 | { |
2690 | CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); | 2700 | CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); |
2691 | m_host.AddScriptLPS(1); | 2701 | m_host.AddScriptLPS(1); |
2702 | |||
2692 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2703 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2693 | int linkNum = link_num.value; | 2704 | int linkNum = link_num.value; |
2694 | if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS)) | 2705 | if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS)) |
@@ -2696,12 +2707,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2696 | UUID npcId; | 2707 | UUID npcId; |
2697 | if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID)) | 2708 | if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID)) |
2698 | return; | 2709 | return; |
2710 | |||
2699 | SceneObjectPart part = null; | 2711 | SceneObjectPart part = null; |
2700 | UUID objectId; | 2712 | UUID objectId; |
2701 | if (UUID.TryParse(LSL_String.ToString(object_key), out objectId)) | 2713 | if (UUID.TryParse(LSL_String.ToString(object_key), out objectId)) |
2702 | part = World.GetSceneObjectPart(objectId); | 2714 | part = World.GetSceneObjectPart(objectId); |
2715 | |||
2703 | if (part == null) | 2716 | if (part == null) |
2704 | return; | 2717 | return; |
2718 | |||
2705 | if (linkNum != ScriptBaseClass.LINK_THIS) | 2719 | if (linkNum != ScriptBaseClass.LINK_THIS) |
2706 | { | 2720 | { |
2707 | if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT) | 2721 | if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT) |
@@ -2716,6 +2730,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2716 | return; | 2730 | return; |
2717 | } | 2731 | } |
2718 | } | 2732 | } |
2733 | |||
2719 | module.Touch(npcId, part.UUID); | 2734 | module.Touch(npcId, part.UUID); |
2720 | } | 2735 | } |
2721 | } | 2736 | } |