diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 0271738aee..f56d17d108 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -33,6 +33,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { @@ -119,6 +120,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } else { + // Check if the xfer is a terrain xfer + IEstateModule estateModule = m_Scene.RequestModuleInterface(); + if (estateModule != null) + { + if (estateModule.IsTerrainXfer(xferID)) + return; + } + m_log.ErrorFormat( "[AGENT ASSET TRANSACTIONS]: Could not find uploader for xfer id {0}, packet id {1}, data length {2}", xferID, packetID, data.Length); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 42db1cf475..17387da751 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -829,26 +829,23 @@ namespace OpenSim.Region.CoreModules.World.Estate private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) { - if (TerrainUploader != null) + lock (this) { - lock (TerrainUploader) + if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID)) { - if (XferID == TerrainUploader.XferID) - { - remoteClient.OnXferReceive -= TerrainUploader.XferReceive; - remoteClient.OnAbortXfer -= AbortTerrainXferHandler; - TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; + remoteClient.OnXferReceive -= TerrainUploader.XferReceive; + remoteClient.OnAbortXfer -= AbortTerrainXferHandler; + TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; - TerrainUploader = null; - remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); - } + TerrainUploader = null; + remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); } } - } + private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) { - lock (TerrainUploader) + lock (this) { remoteClient.OnXferReceive -= TerrainUploader.XferReceive; remoteClient.OnAbortXfer -= AbortTerrainXferHandler; @@ -907,22 +904,32 @@ namespace OpenSim.Region.CoreModules.World.Estate private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) { - if (TerrainUploader == null) + lock (this) { - - TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); - lock (TerrainUploader) + if (TerrainUploader == null) { + m_log.DebugFormat("Starting to receive uploaded terrain"); + TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); remote_client.OnXferReceive += TerrainUploader.XferReceive; remote_client.OnAbortXfer += AbortTerrainXferHandler; TerrainUploader.TerrainUploadDone += HandleTerrainApplication; + TerrainUploader.RequestStartXfer(remote_client); + } + else + { + remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); } - TerrainUploader.RequestStartXfer(remote_client); - } - else + } + + public bool IsTerrainXfer(ulong xferID) + { + lock (this) { - remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); + if (TerrainUploader == null) + return false; + else + return TerrainUploader.XferID == xferID; } } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index b8d8b10068..2d74eaf929 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs @@ -78,7 +78,10 @@ namespace OpenSim.Region.CoreModules.World.Estate /// public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { - if (mXferID == xferID) + if (mXferID != xferID) + return; + + lock (this) { if (m_asset.Data.Length > 1) { @@ -99,7 +102,6 @@ namespace OpenSim.Region.CoreModules.World.Estate if ((packetID & 0x80000000) != 0) { SendCompleteMessage(remoteClient); - } } } diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index d49b24ec0d..944c66b9a6 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs @@ -54,5 +54,10 @@ namespace OpenSim.Region.Framework.Interfaces void setEstateTerrainBaseTexture(int level, UUID texture); void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue); + + /// + /// Returns whether the transfer ID is being used for a terrain transfer. + /// + bool IsTerrainXfer(ulong xferID); } }