From d05b121dfffdc0521f7e87a7324cfea4a7a37ff7 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 29 Nov 2007 06:06:42 +0000 Subject: * Locking on local scope variable does not make sense - every thread will have its own * Locking on value, then changing it does not make sense - lock will happen on old reference * Taking a local copy of the shared resource then locking on the copy does not make sense - lock will happen on copy --- .../Scenes/SceneCommunicationService.cs | 50 ++++++++++------------ 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index c531702..905764d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -35,8 +35,8 @@ namespace OpenSim.Region.Environment.Scenes set { _debugRegionName = value; - - + + } } @@ -177,10 +177,10 @@ namespace OpenSim.Region.Environment.Scenes List neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); //IPEndPoint blah = new IPEndPoint(); - + //blah.Address = region.RemotingAddress; //blah.Port = region.RemotingPort; - + } @@ -232,7 +232,7 @@ namespace OpenSim.Region.Environment.Scenes } - private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle) + private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle) { MainLog.Instance.Notice("INTERGRID", "Starting to inform neighbors that I'm here"); bool regionAccepted = m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); @@ -250,29 +250,23 @@ namespace OpenSim.Region.Environment.Scenes public void InformNeighborsThatRegionisUp(RegionInfo region) { //MainLog.Instance.Verbose("INTER", debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); - List neighbours = new List(); - - lock (neighbours) - { - neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); - if (neighbours != null) - { - for (int i = 0; i < neighbours.Count; i++) - { - - InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; - // race condition! Arg! I hate race conditions. - lock (d) - { - d.BeginInvoke(region, neighbours[i].RegionHandle, - InformNeighborsThatRegionisUpCompleted, - d); - } - } - } - } + + List neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + if (neighbours != null) + { + for (int i = 0; i < neighbours.Count; i++) + { + + InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; + + d.BeginInvoke(region, neighbours[i].RegionHandle, + InformNeighborsThatRegionisUpCompleted, + d); + } + } //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); } + /// /// /// @@ -294,7 +288,7 @@ namespace OpenSim.Region.Environment.Scenes public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) { List mapBlocks; - mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX-4, minY-4, minX+4, minY+4); + mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4); remoteClient.SendMapBlock(mapBlocks); } @@ -373,7 +367,7 @@ namespace OpenSim.Region.Environment.Scenes { foreach (ulong regionHandle in presence.KnownChildRegions) { - + m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, presence.ControllingClient.AgentId); presence.RemoveNeighbourRegion(regionHandle); } -- cgit v1.1