From 3c05d67094f545298dad86df29e6de3a13581617 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 7 Mar 2014 01:36:06 +0000 Subject: [PATCH] Lock m_landlist whilst loading parcels from storage to prevent a race against any parcel auto-creation in GetLandObject() --- .../World/Land/LandManagementModule.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 05f9f26e59..4e111506c8 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -915,10 +915,16 @@ namespace OpenSim.Region.CoreModules.World.Land landID = m_lastLandLocalID; } + else + { + // XXX: We're not currently doing anything if there are no parcels, as this might indicate a race + // condition where this method is being called before land data is loaded. May need to address + // this in another way. - // XXX: We're not currently doing anything if there are no parcels, as this might indicate a race - // condition where this method is being called before land data is loaded. May need to address - // this in another way. + m_log.WarnFormat( + "[{0}]: Ignoring request to auto-create parcel in {1} as there are no other parcels present", + LogHeader, m_scene.Name); + } } ret = m_landList[landID]; @@ -1545,16 +1551,21 @@ namespace OpenSim.Region.CoreModules.World.Land #region Land Object From Storage Functions - public void EventManagerOnIncomingLandDataFromStorage(List data) + private void EventManagerOnIncomingLandDataFromStorage(List data) { // m_log.DebugFormat( // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); - for (int i = 0; i < data.Count; i++) - IncomingLandObjectFromStorage(data[i]); + // Prevent race conditions from any auto-creation of new parcels for varregions whilst we are still loading + // the existing parcels. + lock (m_landList) + { + for (int i = 0; i < data.Count; i++) + IncomingLandObjectFromStorage(data[i]); + } } - public void IncomingLandObjectFromStorage(LandData data) + private void IncomingLandObjectFromStorage(LandData data) { ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); new_land.LandData = data.Copy();