diff options
Diffstat (limited to '')
3 files changed, 94 insertions, 110 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index b557ffe..bba7b9c 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -57,39 +57,36 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
57 | } | 57 | } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Return a xfer uploader if one does not already exist. | 60 | /// Return the xfer uploader for the given transaction. |
61 | /// </summary> | 61 | /// </summary> |
62 | /// <remarks> | ||
63 | /// If an uploader does not already exist for this transaction then it is created, otherwise the existing | ||
64 | /// uploader is returned. | ||
65 | /// </remarks> | ||
62 | /// <param name="transactionID"></param> | 66 | /// <param name="transactionID"></param> |
63 | /// <param name="assetID"> | 67 | /// <returns>The asset xfer uploader</returns> |
64 | /// We must transfer the new asset ID into the uploader on creation, otherwise | 68 | public AssetXferUploader RequestXferUploader(UUID transactionID) |
65 | /// we can see race conditions with other threads which can retrieve an item before it is updated with the new | ||
66 | /// asset id. | ||
67 | /// </param> | ||
68 | /// <returns> | ||
69 | /// The xfer uploader requested. Null if one is already in existence. | ||
70 | /// FIXME: This is a bizarre thing to do, and is probably meant to signal an error condition if multiple | ||
71 | /// transfers are made. Needs to be corrected. | ||
72 | /// </returns> | ||
73 | public AssetXferUploader RequestXferUploader(UUID transactionID, UUID assetID) | ||
74 | { | 69 | { |
70 | AssetXferUploader uploader; | ||
71 | |||
75 | lock (XferUploaders) | 72 | lock (XferUploaders) |
76 | { | 73 | { |
77 | if (!XferUploaders.ContainsKey(transactionID)) | 74 | if (!XferUploaders.ContainsKey(transactionID)) |
78 | { | 75 | { |
79 | AssetXferUploader uploader = new AssetXferUploader(this, m_Scene, assetID, m_dumpAssetsToFile); | 76 | uploader = new AssetXferUploader(this, m_Scene, m_dumpAssetsToFile); |
80 | 77 | ||
81 | // m_log.DebugFormat( | 78 | // m_log.DebugFormat( |
82 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); | 79 | // "[AGENT ASSETS TRANSACTIONS]: Adding asset xfer uploader {0} since it didn't previously exist", transactionID); |
83 | 80 | ||
84 | XferUploaders.Add(transactionID, uploader); | 81 | XferUploaders.Add(transactionID, uploader); |
85 | 82 | } | |
86 | return uploader; | 83 | else |
84 | { | ||
85 | uploader = XferUploaders[transactionID]; | ||
87 | } | 86 | } |
88 | } | 87 | } |
89 | 88 | ||
90 | m_log.WarnFormat("[AGENT ASSETS TRANSACTIONS]: Ignoring request for asset xfer uploader {0} since it already exists", transactionID); | 89 | return uploader; |
91 | |||
92 | return null; | ||
93 | } | 90 | } |
94 | 91 | ||
95 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | 92 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) |
@@ -151,23 +148,11 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
151 | string description, string name, sbyte invType, | 148 | string description, string name, sbyte invType, |
152 | sbyte type, byte wearableType, uint nextOwnerMask) | 149 | sbyte type, byte wearableType, uint nextOwnerMask) |
153 | { | 150 | { |
154 | AssetXferUploader uploader = null; | 151 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
155 | 152 | ||
156 | lock (XferUploaders) | 153 | uploader.RequestCreateInventoryItem( |
157 | { | 154 | remoteClient, transactionID, folderID, callbackID, |
158 | if (XferUploaders.ContainsKey(transactionID)) | 155 | description, name, invType, type, wearableType, nextOwnerMask); |
159 | uploader = XferUploaders[transactionID]; | ||
160 | } | ||
161 | |||
162 | if (uploader != null) | ||
163 | uploader.RequestCreateInventoryItem( | ||
164 | remoteClient, transactionID, folderID, | ||
165 | callbackID, description, name, invType, type, | ||
166 | wearableType, nextOwnerMask); | ||
167 | else | ||
168 | m_log.ErrorFormat( | ||
169 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to create inventory item {1} from {2}", | ||
170 | transactionID, name, remoteClient.Name); | ||
171 | } | 156 | } |
172 | 157 | ||
173 | /// <summary> | 158 | /// <summary> |
@@ -197,69 +182,37 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
197 | SceneObjectPart part, UUID transactionID, | 182 | SceneObjectPart part, UUID transactionID, |
198 | TaskInventoryItem item) | 183 | TaskInventoryItem item) |
199 | { | 184 | { |
200 | AssetXferUploader uploader = null; | 185 | AssetBase asset = GetTransactionAsset(transactionID); |
201 | 186 | ||
202 | lock (XferUploaders) | 187 | // Only legacy viewers use this, and they prefer CAPS, which |
203 | { | 188 | // we have, so this really never runs. |
204 | if (XferUploaders.ContainsKey(transactionID)) | 189 | // Allow it, but only for "safe" types. |
205 | uploader = XferUploaders[transactionID]; | 190 | if ((InventoryType)item.InvType != InventoryType.Notecard && |
206 | } | 191 | (InventoryType)item.InvType != InventoryType.LSL) |
192 | return; | ||
207 | 193 | ||
208 | if (uploader != null) | 194 | if (asset != null) |
209 | { | 195 | { |
210 | AssetBase asset = GetTransactionAsset(transactionID); | ||
211 | |||
212 | // Only legacy viewers use this, and they prefer CAPS, which | ||
213 | // we have, so this really never runs. | ||
214 | // Allow it, but only for "safe" types. | ||
215 | if ((InventoryType)item.InvType != InventoryType.Notecard && | ||
216 | (InventoryType)item.InvType != InventoryType.LSL) | ||
217 | return; | ||
218 | |||
219 | if (asset != null) | ||
220 | { | ||
221 | // m_log.DebugFormat( | 196 | // m_log.DebugFormat( |
222 | // "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}", | 197 | // "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}", |
223 | // item.Name, part.Name, transactionID); | 198 | // item.Name, part.Name, transactionID); |
224 | 199 | ||
225 | asset.FullID = UUID.Random(); | 200 | asset.FullID = UUID.Random(); |
226 | asset.Name = item.Name; | 201 | asset.Name = item.Name; |
227 | asset.Description = item.Description; | 202 | asset.Description = item.Description; |
228 | asset.Type = (sbyte)item.Type; | 203 | asset.Type = (sbyte)item.Type; |
229 | item.AssetID = asset.FullID; | 204 | item.AssetID = asset.FullID; |
230 | 205 | ||
231 | m_Scene.AssetService.Store(asset); | 206 | m_Scene.AssetService.Store(asset); |
232 | } | ||
233 | } | ||
234 | else | ||
235 | { | ||
236 | m_log.ErrorFormat( | ||
237 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update task inventory item {1} in {2}", | ||
238 | transactionID, item.Name, part.Name); | ||
239 | } | 207 | } |
240 | } | 208 | } |
241 | 209 | ||
242 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, | 210 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, |
243 | UUID transactionID, InventoryItemBase item) | 211 | UUID transactionID, InventoryItemBase item) |
244 | { | 212 | { |
245 | AssetXferUploader uploader = null; | 213 | AssetXferUploader uploader = RequestXferUploader(transactionID); |
246 | |||
247 | lock (XferUploaders) | ||
248 | { | ||
249 | if (XferUploaders.ContainsKey(transactionID)) | ||
250 | uploader = XferUploaders[transactionID]; | ||
251 | } | ||
252 | 214 | ||
253 | if (uploader != null) | 215 | uploader.RequestUpdateInventoryItem(remoteClient, transactionID, item); |
254 | { | ||
255 | uploader.RequestUpdateInventoryItem(remoteClient, transactionID, item); | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | m_log.ErrorFormat( | ||
260 | "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to update inventory item {1} for {2}", | ||
261 | transactionID, item.Name, remoteClient.Name); | ||
262 | } | ||
263 | } | 216 | } |
264 | } | 217 | } |
265 | } | 218 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 7081989..10a0794 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -274,13 +274,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
274 | } | 274 | } |
275 | 275 | ||
276 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); | 276 | AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); |
277 | AssetXferUploader uploader = transactions.RequestXferUploader(transaction, assetID); | 277 | AssetXferUploader uploader = transactions.RequestXferUploader(transaction); |
278 | 278 | uploader.StartUpload(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); | |
279 | if (uploader != null) | ||
280 | { | ||
281 | uploader.Initialise(remoteClient, assetID, transaction, type, | ||
282 | data, storeLocal, tempFile); | ||
283 | } | ||
284 | } | 279 | } |
285 | 280 | ||
286 | /// <summary> | 281 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index ec4dfd0..9f05120 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -41,11 +41,26 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Upload state. | ||
45 | /// </summary> | ||
46 | /// <remarks> | ||
47 | /// New -> Uploading -> Complete | ||
48 | /// </remarks> | ||
49 | private enum UploadState | ||
50 | { | ||
51 | New, | ||
52 | Uploading, | ||
53 | Complete | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
44 | /// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we | 57 | /// Reference to the object that holds this uploader. Used to remove ourselves from it's list if we |
45 | /// are performing a delayed update. | 58 | /// are performing a delayed update. |
46 | /// </summary> | 59 | /// </summary> |
47 | AgentAssetTransactions m_transactions; | 60 | AgentAssetTransactions m_transactions; |
48 | 61 | ||
62 | private UploadState m_uploadState = UploadState.New; | ||
63 | |||
49 | private AssetBase m_asset; | 64 | private AssetBase m_asset; |
50 | private UUID InventFolder = UUID.Zero; | 65 | private UUID InventFolder = UUID.Zero; |
51 | private sbyte invType = 0; | 66 | private sbyte invType = 0; |
@@ -57,7 +72,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
57 | 72 | ||
58 | private string m_description = String.Empty; | 73 | private string m_description = String.Empty; |
59 | private bool m_dumpAssetToFile; | 74 | private bool m_dumpAssetToFile; |
60 | private bool m_finished = false; | ||
61 | private string m_name = String.Empty; | 75 | private string m_name = String.Empty; |
62 | private bool m_storeLocal; | 76 | private bool m_storeLocal; |
63 | private uint nextPerm = 0; | 77 | private uint nextPerm = 0; |
@@ -68,11 +82,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
68 | public ulong XferID; | 82 | public ulong XferID; |
69 | private Scene m_Scene; | 83 | private Scene m_Scene; |
70 | 84 | ||
71 | public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, UUID assetID, bool dumpAssetToFile) | 85 | public AssetXferUploader(AgentAssetTransactions transactions, Scene scene, bool dumpAssetToFile) |
72 | { | 86 | { |
73 | m_transactions = transactions; | 87 | m_transactions = transactions; |
74 | m_Scene = scene; | 88 | m_Scene = scene; |
75 | m_asset = new AssetBase() { FullID = assetID }; | ||
76 | m_dumpAssetToFile = dumpAssetToFile; | 89 | m_dumpAssetToFile = dumpAssetToFile; |
77 | } | 90 | } |
78 | 91 | ||
@@ -118,20 +131,43 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
118 | } | 131 | } |
119 | 132 | ||
120 | /// <summary> | 133 | /// <summary> |
121 | /// Initialise asset transfer from the client | 134 | /// Start asset transfer from the client |
122 | /// </summary> | 135 | /// </summary> |
123 | /// <param name="xferID"></param> | 136 | /// <param name="remoteClient"></param> |
124 | /// <param name="packetID"></param> | 137 | /// <param name="assetID"></param> |
125 | /// <param name="data"></param> | 138 | /// <param name="transaction"></param> |
126 | public void Initialise(IClientAPI remoteClient, UUID assetID, | 139 | /// <param name="type"></param> |
127 | UUID transaction, sbyte type, byte[] data, bool storeLocal, | 140 | /// <param name="data"> |
128 | bool tempFile) | 141 | /// Optional data. If present then the asset is created immediately with this data |
142 | /// rather than requesting an upload from the client. The data must be longer than 2 bytes. | ||
143 | /// </param> | ||
144 | /// <param name="storeLocal"></param> | ||
145 | /// <param name="tempFile"></param> | ||
146 | public void StartUpload( | ||
147 | IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal, | ||
148 | bool tempFile) | ||
129 | { | 149 | { |
130 | // m_log.DebugFormat( | 150 | // m_log.DebugFormat( |
131 | // "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}", | 151 | // "[ASSET XFER UPLOADER]: Initialised xfer from {0}, asset {1}, transaction {2}, type {3}, storeLocal {4}, tempFile {5}, already received data length {6}", |
132 | // remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length); | 152 | // remoteClient.Name, assetID, transaction, type, storeLocal, tempFile, data.Length); |
133 | 153 | ||
154 | lock (this) | ||
155 | { | ||
156 | if (m_uploadState != UploadState.New) | ||
157 | { | ||
158 | m_log.WarnFormat( | ||
159 | "[ASSET XFER UPLOADER]: Tried to start upload of asset {0}, transaction {1} for {2} but this is already in state {3}. Aborting.", | ||
160 | assetID, transaction, remoteClient.Name, m_uploadState); | ||
161 | |||
162 | return; | ||
163 | } | ||
164 | |||
165 | m_uploadState = UploadState.Uploading; | ||
166 | } | ||
167 | |||
134 | ourClient = remoteClient; | 168 | ourClient = remoteClient; |
169 | |||
170 | m_asset = new AssetBase() { FullID = assetID }; | ||
135 | m_asset.Name = "blank"; | 171 | m_asset.Name = "blank"; |
136 | m_asset.Description = "empty"; | 172 | m_asset.Description = "empty"; |
137 | m_asset.Type = type; | 173 | m_asset.Type = type; |
@@ -166,14 +202,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
166 | 202 | ||
167 | protected void SendCompleteMessage() | 203 | protected void SendCompleteMessage() |
168 | { | 204 | { |
169 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, | ||
170 | m_asset.FullID); | ||
171 | |||
172 | // We must lock in order to avoid a race with a separate thread dealing with an inventory item or create | 205 | // We must lock in order to avoid a race with a separate thread dealing with an inventory item or create |
173 | // message from other client UDP. | 206 | // message from other client UDP. |
174 | lock (this) | 207 | lock (this) |
175 | { | 208 | { |
176 | m_finished = true; | 209 | m_uploadState = UploadState.Complete; |
210 | |||
211 | ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); | ||
212 | |||
177 | if (m_createItem) | 213 | if (m_createItem) |
178 | { | 214 | { |
179 | DoCreateItem(m_createItemCallback); | 215 | DoCreateItem(m_createItemCallback); |
@@ -243,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
243 | // We must lock to avoid a race with a separate thread uploading the asset. | 279 | // We must lock to avoid a race with a separate thread uploading the asset. |
244 | lock (this) | 280 | lock (this) |
245 | { | 281 | { |
246 | if (m_finished) | 282 | if (m_uploadState == UploadState.Complete) |
247 | { | 283 | { |
248 | DoCreateItem(callbackID); | 284 | DoCreateItem(callbackID); |
249 | } | 285 | } |
@@ -271,7 +307,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
271 | item.AssetID = m_asset.FullID; | 307 | item.AssetID = m_asset.FullID; |
272 | m_Scene.InventoryService.UpdateItem(item); | 308 | m_Scene.InventoryService.UpdateItem(item); |
273 | 309 | ||
274 | if (m_finished) | 310 | if (m_uploadState == UploadState.Complete) |
275 | { | 311 | { |
276 | StoreAssetForItemUpdate(item); | 312 | StoreAssetForItemUpdate(item); |
277 | } | 313 | } |
@@ -334,7 +370,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
334 | /// <returns>null if the asset has not finished uploading</returns> | 370 | /// <returns>null if the asset has not finished uploading</returns> |
335 | public AssetBase GetAssetData() | 371 | public AssetBase GetAssetData() |
336 | { | 372 | { |
337 | if (m_finished) | 373 | if (m_uploadState == UploadState.Complete) |
338 | { | 374 | { |
339 | return m_asset; | 375 | return m_asset; |
340 | } | 376 | } |
@@ -342,4 +378,4 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
342 | return null; | 378 | return null; |
343 | } | 379 | } |
344 | } | 380 | } |
345 | } | 381 | } \ No newline at end of file |