diff options
author | Oren Hurvitz | 2013-09-18 15:55:42 +0300 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-10-15 00:12:56 +0100 |
commit | f106ba87ca92b477b32a84aa246e4b4481b0980b (patch) | |
tree | ed2908479255e86056b364f9dc3b5ddc1eba7ca7 | |
parent | This is Npgsql2.0.12.0-bin-ms-net3.5sp1 (diff) | |
download | opensim-SC-f106ba87ca92b477b32a84aa246e4b4481b0980b.zip opensim-SC-f106ba87ca92b477b32a84aa246e4b4481b0980b.tar.gz opensim-SC-f106ba87ca92b477b32a84aa246e4b4481b0980b.tar.bz2 opensim-SC-f106ba87ca92b477b32a84aa246e4b4481b0980b.tar.xz |
Made terrain uploads thread-safe
Diffstat (limited to '')
4 files changed, 45 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 0271738..f56d17d 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -33,6 +33,7 @@ using OpenSim.Framework; | |||
33 | 33 | ||
34 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
36 | using OpenSim.Region.Framework.Interfaces; | ||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | 38 | namespace OpenSim.Region.CoreModules.Agent.AssetTransaction |
38 | { | 39 | { |
@@ -119,6 +120,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
119 | } | 120 | } |
120 | else | 121 | else |
121 | { | 122 | { |
123 | // Check if the xfer is a terrain xfer | ||
124 | IEstateModule estateModule = m_Scene.RequestModuleInterface<IEstateModule>(); | ||
125 | if (estateModule != null) | ||
126 | { | ||
127 | if (estateModule.IsTerrainXfer(xferID)) | ||
128 | return; | ||
129 | } | ||
130 | |||
122 | m_log.ErrorFormat( | 131 | m_log.ErrorFormat( |
123 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader for xfer id {0}, packet id {1}, data length {2}", | 132 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader for xfer id {0}, packet id {1}, data length {2}", |
124 | xferID, packetID, data.Length); | 133 | xferID, packetID, data.Length); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 42db1cf..17387da 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 | |||
829 | 829 | ||
830 | private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) | 830 | private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID) |
831 | { | 831 | { |
832 | if (TerrainUploader != null) | 832 | lock (this) |
833 | { | 833 | { |
834 | lock (TerrainUploader) | 834 | if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID)) |
835 | { | 835 | { |
836 | if (XferID == TerrainUploader.XferID) | 836 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; |
837 | { | 837 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; |
838 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | 838 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; |
839 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | ||
840 | TerrainUploader.TerrainUploadDone -= HandleTerrainApplication; | ||
841 | 839 | ||
842 | TerrainUploader = null; | 840 | TerrainUploader = null; |
843 | remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); | 841 | remoteClient.SendAlertMessage("Terrain Upload aborted by the client"); |
844 | } | ||
845 | } | 842 | } |
846 | } | 843 | } |
847 | |||
848 | } | 844 | } |
845 | |||
849 | private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) | 846 | private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient) |
850 | { | 847 | { |
851 | lock (TerrainUploader) | 848 | lock (this) |
852 | { | 849 | { |
853 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; | 850 | remoteClient.OnXferReceive -= TerrainUploader.XferReceive; |
854 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; | 851 | remoteClient.OnAbortXfer -= AbortTerrainXferHandler; |
@@ -907,22 +904,32 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
907 | 904 | ||
908 | private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) | 905 | private void handleUploadTerrain(IClientAPI remote_client, string clientFileName) |
909 | { | 906 | { |
910 | if (TerrainUploader == null) | 907 | lock (this) |
911 | { | 908 | { |
912 | 909 | if (TerrainUploader == null) | |
913 | TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); | ||
914 | lock (TerrainUploader) | ||
915 | { | 910 | { |
911 | m_log.DebugFormat("Starting to receive uploaded terrain"); | ||
912 | TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName); | ||
916 | remote_client.OnXferReceive += TerrainUploader.XferReceive; | 913 | remote_client.OnXferReceive += TerrainUploader.XferReceive; |
917 | remote_client.OnAbortXfer += AbortTerrainXferHandler; | 914 | remote_client.OnAbortXfer += AbortTerrainXferHandler; |
918 | TerrainUploader.TerrainUploadDone += HandleTerrainApplication; | 915 | TerrainUploader.TerrainUploadDone += HandleTerrainApplication; |
916 | TerrainUploader.RequestStartXfer(remote_client); | ||
917 | } | ||
918 | else | ||
919 | { | ||
920 | remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); | ||
919 | } | 921 | } |
920 | TerrainUploader.RequestStartXfer(remote_client); | ||
921 | |||
922 | } | 922 | } |
923 | else | 923 | } |
924 | |||
925 | public bool IsTerrainXfer(ulong xferID) | ||
926 | { | ||
927 | lock (this) | ||
924 | { | 928 | { |
925 | remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!"); | 929 | if (TerrainUploader == null) |
930 | return false; | ||
931 | else | ||
932 | return TerrainUploader.XferID == xferID; | ||
926 | } | 933 | } |
927 | } | 934 | } |
928 | 935 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index b8d8b10..2d74eaf 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 | |||
78 | /// <param name="data"></param> | 78 | /// <param name="data"></param> |
79 | public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) | 79 | public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) |
80 | { | 80 | { |
81 | if (mXferID == xferID) | 81 | if (mXferID != xferID) |
82 | return; | ||
83 | |||
84 | lock (this) | ||
82 | { | 85 | { |
83 | if (m_asset.Data.Length > 1) | 86 | if (m_asset.Data.Length > 1) |
84 | { | 87 | { |
@@ -99,7 +102,6 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
99 | if ((packetID & 0x80000000) != 0) | 102 | if ((packetID & 0x80000000) != 0) |
100 | { | 103 | { |
101 | SendCompleteMessage(remoteClient); | 104 | SendCompleteMessage(remoteClient); |
102 | |||
103 | } | 105 | } |
104 | } | 106 | } |
105 | } | 107 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index d49b24e..944c66b 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs | |||
@@ -54,5 +54,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
54 | 54 | ||
55 | void setEstateTerrainBaseTexture(int level, UUID texture); | 55 | void setEstateTerrainBaseTexture(int level, UUID texture); |
56 | void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue); | 56 | void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue); |
57 | |||
58 | /// <summary> | ||
59 | /// Returns whether the transfer ID is being used for a terrain transfer. | ||
60 | /// </summary> | ||
61 | bool IsTerrainXfer(ulong xferID); | ||
57 | } | 62 | } |
58 | } | 63 | } |