Made terrain uploads thread-safe
parent
a27c2432bb
commit
f106ba87ca
|
@ -33,6 +33,7 @@ using OpenSim.Framework;
|
||||||
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
{
|
{
|
||||||
|
@ -119,6 +120,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Check if the xfer is a terrain xfer
|
||||||
|
IEstateModule estateModule = m_Scene.RequestModuleInterface<IEstateModule>();
|
||||||
|
if (estateModule != null)
|
||||||
|
{
|
||||||
|
if (estateModule.IsTerrainXfer(xferID))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT ASSET TRANSACTIONS]: Could not find uploader for xfer id {0}, packet id {1}, data length {2}",
|
"[AGENT ASSET TRANSACTIONS]: Could not find uploader for xfer id {0}, packet id {1}, data length {2}",
|
||||||
xferID, packetID, data.Length);
|
xferID, packetID, data.Length);
|
||||||
|
|
|
@ -829,11 +829,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
|
|
||||||
private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
|
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.OnXferReceive -= TerrainUploader.XferReceive;
|
||||||
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
|
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
|
||||||
|
@ -845,10 +843,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
|
private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
lock (TerrainUploader)
|
lock (this)
|
||||||
{
|
{
|
||||||
remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
|
remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
|
||||||
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
|
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
|
||||||
|
@ -906,25 +903,35 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
|
private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
{
|
{
|
||||||
if (TerrainUploader == null)
|
if (TerrainUploader == null)
|
||||||
{
|
{
|
||||||
|
m_log.DebugFormat("Starting to receive uploaded terrain");
|
||||||
TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
|
TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
|
||||||
lock (TerrainUploader)
|
|
||||||
{
|
|
||||||
remote_client.OnXferReceive += TerrainUploader.XferReceive;
|
remote_client.OnXferReceive += TerrainUploader.XferReceive;
|
||||||
remote_client.OnAbortXfer += AbortTerrainXferHandler;
|
remote_client.OnAbortXfer += AbortTerrainXferHandler;
|
||||||
TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
|
TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
|
||||||
}
|
|
||||||
TerrainUploader.RequestStartXfer(remote_client);
|
TerrainUploader.RequestStartXfer(remote_client);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
|
remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsTerrainXfer(ulong xferID)
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
if (TerrainUploader == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return TerrainUploader.XferID == xferID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
|
private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
|
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)
|
if (m_asset.Data.Length > 1)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +102,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
if ((packetID & 0x80000000) != 0)
|
if ((packetID & 0x80000000) != 0)
|
||||||
{
|
{
|
||||||
SendCompleteMessage(remoteClient);
|
SendCompleteMessage(remoteClient);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,5 +54,10 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
|
|
||||||
void setEstateTerrainBaseTexture(int level, UUID texture);
|
void setEstateTerrainBaseTexture(int level, UUID texture);
|
||||||
void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue);
|
void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether the transfer ID is being used for a terrain transfer.
|
||||||
|
/// </summary>
|
||||||
|
bool IsTerrainXfer(ulong xferID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue