From 882566a32f0784894571ebc1d50f7a2f2d7500d0 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 22 Feb 2008 21:18:37 +0000 Subject: [PATCH] * Converted the last of the events to the private delegate instance method to avoid race conditions. --- OpenSim/Framework/RegionCommsListener.cs | 74 ++++++++++++------- .../Communications/Local/LocalLoginService.cs | 7 +- .../Communications/OGS1/OGS1InterSimComms.cs | 43 +++++++---- .../Scenes/SceneCommunicationService.cs | 52 ++++++++----- 4 files changed, 114 insertions(+), 62 deletions(-) diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs index 41577c64fa..ae5279d9c4 100644 --- a/OpenSim/Framework/RegionCommsListener.cs +++ b/OpenSim/Framework/RegionCommsListener.cs @@ -45,8 +45,18 @@ namespace OpenSim.Framework public event CloseAgentConnection OnCloseAgentConnection; public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; - + private ExpectUserDelegate handler001 = null; // OnExpectUser + private ExpectPrimDelegate handler002 = null; // OnExpectPrim; + private GenericCall2 handler003 = null; // OnExpectChildAgent; + private AgentCrossing handler004 = null; // OnAvatarCrossingIntoRegion; + private PrimCrossing handler005 = null; // OnPrimCrossingIntoRegion; + private UpdateNeighbours handler006 = null; // OnNeighboursUpdate; + private AcknowledgeAgentCross handler007 = null; // OnAcknowledgeAgentCrossed; + private AcknowledgePrimCross handler008 = null; // OnAcknowledgePrimCrossed; + private CloseAgentConnection handler009 = null; // OnCloseAgentConnection; + private RegionUp handler010 = null; // OnRegionUp; + private ChildAgentUpdate handler011 = null; // OnChildAgentUpdate; public string debugRegionName = String.Empty; @@ -58,9 +68,10 @@ namespace OpenSim.Framework /// public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) { - if (OnExpectUser != null) + handler001 = OnExpectUser; + if (handler001 != null) { - OnExpectUser(regionHandle, agent); + handler001(regionHandle, agent); return true; } @@ -70,9 +81,10 @@ namespace OpenSim.Framework public virtual bool TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData) { - if (OnExpectPrim != null) + handler002 = OnExpectPrim; + if (handler002 != null) { - OnExpectPrim(regionHandle, primID, objData); + handler002(regionHandle, primID, objData); return true; } return false; @@ -80,9 +92,10 @@ namespace OpenSim.Framework public virtual bool TriggerRegionUp(RegionInfo region) { - if (OnRegionUp != null) + handler010 = OnRegionUp; + if (handler010 != null) { - OnRegionUp(region); + handler010(region); return true; } return false; @@ -90,9 +103,10 @@ namespace OpenSim.Framework public virtual bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { - if (OnChildAgentUpdate != null) + handler011 = OnChildAgentUpdate; + if (handler011 != null) { - OnChildAgentUpdate(regionHandle, cAgentData); + handler011(regionHandle, cAgentData); return true; } return false; @@ -101,9 +115,10 @@ namespace OpenSim.Framework public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { - if (OnAvatarCrossingIntoRegion != null) + handler004 = OnAvatarCrossingIntoRegion; + if (handler004 != null) { - OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); + handler004(regionHandle, agentID, position, isFlying); return true; } return false; @@ -112,9 +127,10 @@ namespace OpenSim.Framework public virtual bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { - if (OnPrimCrossingIntoRegion != null) + handler005 = OnPrimCrossingIntoRegion; + if (handler005 != null) { - OnPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical); + handler005(regionHandle, primID, position, isPhysical); return true; } return false; @@ -122,9 +138,10 @@ namespace OpenSim.Framework public virtual bool TriggerAcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) { - if (OnAcknowledgeAgentCrossed != null) + handler007 = OnAcknowledgeAgentCrossed; + if (handler007 != null) { - OnAcknowledgeAgentCrossed(regionHandle, agentID); + handler007(regionHandle, agentID); return true; } return false; @@ -132,9 +149,10 @@ namespace OpenSim.Framework public virtual bool TriggerAcknowledgePrimCrossed(ulong regionHandle, LLUUID primID) { - if (OnAcknowledgePrimCrossed != null) + handler008 = OnAcknowledgePrimCrossed; + if (handler008 != null) { - OnAcknowledgePrimCrossed(regionHandle, primID); + handler008(regionHandle, primID); return true; } return false; @@ -142,9 +160,10 @@ namespace OpenSim.Framework public virtual bool TriggerCloseAgentConnection(ulong regionHandle, LLUUID agentID) { - if (OnCloseAgentConnection != null) + handler009 = OnCloseAgentConnection; + if (handler009 != null) { - OnCloseAgentConnection(regionHandle, agentID); + handler009(regionHandle, agentID); return true; } @@ -158,9 +177,10 @@ namespace OpenSim.Framework /// public virtual bool TriggerExpectChildAgent() { - if (OnExpectChildAgent != null) + handler003 = OnExpectChildAgent; + if (handler003 != null) { - OnExpectChildAgent(); + handler003(); return true; } @@ -175,9 +195,10 @@ namespace OpenSim.Framework /// public virtual bool TriggerOnNeighboursUpdate(List neighbours) { - if (OnNeighboursUpdate != null) + handler006 = OnNeighboursUpdate; + if (handler006 != null) { - OnNeighboursUpdate(neighbours); + handler006(neighbours); return true; } @@ -186,10 +207,11 @@ namespace OpenSim.Framework public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) { - if (OnCloseAgentConnection != null) - return OnCloseAgentConnection(regionHandle, agentID); + handler009 = OnCloseAgentConnection; + if (handler009 != null) + return handler009(regionHandle, agentID); return false; } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index b480a1a30e..0e9b3d0e5a 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -55,6 +55,8 @@ namespace OpenSim.Region.Communications.Local public event LoginToRegionEvent OnLoginToRegion; + private LoginToRegionEvent handler001 = null; // OnLoginToRegion; + public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) @@ -161,9 +163,10 @@ namespace OpenSim.Region.Communications.Local _login.StartPos = new LLVector3(128, 128, 70); _login.CapsPath = capsPath; - if (OnLoginToRegion != null) + handler001 = OnLoginToRegion; + if (handler001 != null) { - OnLoginToRegion(currentRegion, _login); + handler001(currentRegion, _login); } } else diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs index 3cde55c7a9..d21852d173 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs @@ -59,6 +59,13 @@ namespace OpenSim.Region.Communications.OGS1 public event ChildAgentUpdate OnChildAgentUpdate; public event TellRegionToCloseChildConnection OnTellRegionToCloseChildConnection; + private InformRegionChild handler001 = null; // OnChildAgent; + private ExpectArrival handler002 = null; // OnArrival; + private InformRegionPrimGroup handler003 = null; // OnPrimGroupNear; + private PrimGroupArrival handler004 = null; // OnPrimGroupArrival; + private RegionUp handler005 = null; // OnRegionUp; + private ChildAgentUpdate handler006 = null; // OnChildAgentUpdate; + private TellRegionToCloseChildConnection handler007 = null; // OnTellRegionToCloseChildConnection; static InterRegionSingleton() @@ -76,64 +83,70 @@ namespace OpenSim.Region.Communications.OGS1 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) { - if (OnChildAgent != null) + handler001 = OnChildAgent; + if (handler001 != null) { - return OnChildAgent(regionHandle, agentData); + return handler001(regionHandle, agentData); } return false; } public bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle) { - if (OnRegionUp != null) + handler005 = OnRegionUp; + if (handler005 != null) { - return OnRegionUp(sregion, regionhandle); + return handler005(sregion, regionhandle); } return false; } public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentUpdate) { - if (OnChildAgentUpdate != null) + handler006 = OnChildAgentUpdate; + if (handler006 != null) { - return OnChildAgentUpdate(regionHandle, cAgentUpdate); + return handler006(regionHandle, cAgentUpdate); } return false; } public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { - if (OnArrival != null) + handler002 = OnArrival; + if (handler002 != null) { - return OnArrival(regionHandle, agentID, position, isFlying); + return handler002(regionHandle, agentID, position, isFlying); } return false; } public bool InformRegionPrim(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { - if (OnPrimGroupNear != null) + handler003 = OnPrimGroupNear; + if (handler003 != null) { - return OnPrimGroupNear(regionHandle, primID, position, isPhysical); + return handler003(regionHandle, primID, position, isPhysical); } return false; } public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { - if (OnPrimGroupArrival != null) + handler004 = OnPrimGroupArrival; + if (handler004 != null) { - return OnPrimGroupArrival(regionHandle, primID, objData); + return handler004(regionHandle, primID, objData); } return false; } public bool TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) { - if (OnTellRegionToCloseChildConnection != null) + handler007 = OnTellRegionToCloseChildConnection; + if (handler007 != null) { - - return OnTellRegionToCloseChildConnection(regionHandle, agentID); + return handler007(regionHandle, agentID); } return false; } diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index e51438dcba..4afc7222ef 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -57,8 +57,15 @@ namespace OpenSim.Region.Environment.Scenes public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; - + private AgentCrossing handler001 = null; // OnAvatarCrossingIntoRegion; + private ExpectUserDelegate handler002 = null; // OnExpectUser; + private ExpectPrimDelegate handler003 = null; // OnExpectPrim; + private CloseAgentConnection handler004 = null; // OnCloseAgentConnection; + private PrimCrossing handler005 = null; // OnPrimCrossingIntoRegion; + private RegionUp handler006 = null; // OnRegionUp; + private ChildAgentUpdate handler007 = null; // OnChildAgentUpdate; + private RemoveKnownRegionsFromAvatarList handler008 = null; // OnRemoveKnownRegionFromAvatar; public KillObjectDelegate KillObject; public string _debugRegionName = String.Empty; @@ -125,27 +132,30 @@ namespace OpenSim.Region.Environment.Scenes /// protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent) { - if (OnExpectUser != null) + handler002 = OnExpectUser; + if (handler002 != null) { //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname); - OnExpectUser(regionHandle, agent); + handler002(regionHandle, agent); } } protected bool newRegionUp(RegionInfo region) { - if (OnRegionUp != null) + handler006 = OnRegionUp; + if (handler006 != null) { //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName); - OnRegionUp(region); + handler006(region); } return true; } protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { - if (OnChildAgentUpdate != null) - OnChildAgentUpdate(regionHandle, cAgentData); + handler007 = OnChildAgentUpdate; + if (handler007 != null) + handler007(regionHandle, cAgentData); return true; @@ -153,36 +163,39 @@ namespace OpenSim.Region.Environment.Scenes protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { - if (OnAvatarCrossingIntoRegion != null) + handler001 = OnAvatarCrossingIntoRegion; + if (handler001 != null) { - OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); + handler001(regionHandle, agentID, position, isFlying); } } protected void IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData) { - if (OnExpectPrim != null) + handler003 = OnExpectPrim; + if (handler003 != null) { - OnExpectPrim(regionHandle, primID, objXMLData); + handler003(regionHandle, primID, objXMLData); } } protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { - if (OnPrimCrossingIntoRegion != null) + handler005 = OnPrimCrossingIntoRegion; + if (handler005 != null) { - OnPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical); + handler005(regionHandle, primID, position, isPhysical); } } protected bool CloseConnection(ulong regionHandle, LLUUID agentID) { m_log.Info("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID.ToString()); - - if (OnCloseAgentConnection != null) + handler004 = OnCloseAgentConnection; + if (handler004 != null) { - return OnCloseAgentConnection(regionHandle, agentID); + return handler004(regionHandle, agentID); } return false; } @@ -424,9 +437,10 @@ namespace OpenSim.Region.Environment.Scenes // We remove the list of known regions from the agent's known region list through an event // to scene, because, if an agent logged of, it's likely that there will be no scene presence // by the time we get to this part of the method. - if (OnRemoveKnownRegionFromAvatar != null) + handler008 = OnRemoveKnownRegionFromAvatar; + if (handler008 != null) { - OnRemoveKnownRegionFromAvatar(agentID,regionlst); + handler008(agentID, regionlst); } } @@ -605,4 +619,4 @@ namespace OpenSim.Region.Environment.Scenes return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); } } -} \ No newline at end of file +}