diff options
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4765548..664625e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | ||
32 | using System.Threading; | 31 | using System.Threading; |
33 | using libsecondlife; | 32 | using libsecondlife; |
34 | using libsecondlife.Packets; | 33 | using libsecondlife.Packets; |
@@ -92,7 +91,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
92 | Thread.Sleep(500); | 91 | Thread.Sleep(500); |
93 | } | 92 | } |
94 | catch (Exception e) | 93 | catch (Exception e) |
95 | { | 94 | { |
96 | m_log.Error("ASSETCACHE", e.ToString()); | 95 | m_log.Error("ASSETCACHE", e.ToString()); |
97 | } | 96 | } |
98 | } | 97 | } |
@@ -177,30 +176,29 @@ namespace OpenSim.Framework.Communications.Cache | |||
177 | // packets from the client. | 176 | // packets from the client. |
178 | int pollPeriod = 200; | 177 | int pollPeriod = 200; |
179 | int maxPolls = 15; | 178 | int maxPolls = 15; |
180 | 179 | ||
181 | AssetBase asset = GetCachedAsset(assetID); | 180 | AssetBase asset = GetCachedAsset(assetID); |
182 | if (asset != null) | 181 | if (asset != null) |
183 | { | 182 | { |
184 | return asset; | 183 | return asset; |
185 | } | 184 | } |
186 | 185 | ||
187 | m_assetServer.RequestAsset(assetID, isTexture); | 186 | m_assetServer.RequestAsset(assetID, isTexture); |
188 | 187 | ||
189 | do | 188 | do |
190 | { | 189 | { |
191 | Thread.Sleep(pollPeriod); | 190 | Thread.Sleep(pollPeriod); |
192 | 191 | ||
193 | asset = GetCachedAsset(assetID); | 192 | asset = GetCachedAsset(assetID); |
194 | if (asset != null) | 193 | if (asset != null) |
195 | { | 194 | { |
196 | return asset; | 195 | return asset; |
197 | } | 196 | } |
198 | } | 197 | } while (--maxPolls > 0); |
199 | while (--maxPolls > 0); | 198 | |
200 | |||
201 | MainLog.Instance.Warn( | 199 | MainLog.Instance.Warn( |
202 | "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached"); | 200 | "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached"); |
203 | 201 | ||
204 | return null; | 202 | return null; |
205 | } | 203 | } |
206 | 204 | ||
@@ -368,12 +366,13 @@ namespace OpenSim.Framework.Communications.Cache | |||
368 | { | 366 | { |
369 | // over max number of bytes so split up file | 367 | // over max number of bytes so split up file |
370 | long restData = data.LongLength - m_maxPacketSize; | 368 | long restData = data.LongLength - m_maxPacketSize; |
371 | int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize); | 369 | int restPackets = (int) ((restData + m_maxPacketSize - 1)/m_maxPacketSize); |
372 | numPackets += restPackets; | 370 | numPackets += restPackets; |
373 | } | 371 | } |
374 | 372 | ||
375 | return numPackets; | 373 | return numPackets; |
376 | } | 374 | } |
375 | |||
377 | #region Assets | 376 | #region Assets |
378 | 377 | ||
379 | /// <summary> | 378 | /// <summary> |
@@ -448,7 +447,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
448 | AssetRequest req; | 447 | AssetRequest req; |
449 | for (int i = 0; i < num; i++) | 448 | for (int i = 0; i < num; i++) |
450 | { | 449 | { |
451 | req = (AssetRequest)AssetRequests[i]; | 450 | req = (AssetRequest) AssetRequests[i]; |
452 | //Console.WriteLine("sending asset " + req.RequestAssetID); | 451 | //Console.WriteLine("sending asset " + req.RequestAssetID); |
453 | TransferInfoPacket Transfer = new TransferInfoPacket(); | 452 | TransferInfoPacket Transfer = new TransferInfoPacket(); |
454 | Transfer.TransferInfo.ChannelType = 2; | 453 | Transfer.TransferInfo.ChannelType = 2; |
@@ -458,7 +457,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
458 | { | 457 | { |
459 | Transfer.TransferInfo.Params = new byte[20]; | 458 | Transfer.TransferInfo.Params = new byte[20]; |
460 | Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | 459 | Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); |
461 | int assType = (int)req.AssetInf.Type; | 460 | int assType = (int) req.AssetInf.Type; |
462 | Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); | 461 | Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); |
463 | } | 462 | } |
464 | else if (req.AssetRequestSource == 3) | 463 | else if (req.AssetRequestSource == 3) |
@@ -468,7 +467,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
468 | //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | 467 | //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); |
469 | //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); | 468 | //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); |
470 | } | 469 | } |
471 | Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; | 470 | Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; |
472 | Transfer.TransferInfo.TransferID = req.TransferRequestID; | 471 | Transfer.TransferInfo.TransferID = req.TransferRequestID; |
473 | req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); | 472 | req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); |
474 | 473 | ||
@@ -488,20 +487,20 @@ namespace OpenSim.Framework.Communications.Cache | |||
488 | // libsecondlife hardcodes 1500 as the maximum data chunk size | 487 | // libsecondlife hardcodes 1500 as the maximum data chunk size |
489 | int maxChunkSize = 1500; | 488 | int maxChunkSize = 1500; |
490 | int packetNumber = 0; | 489 | int packetNumber = 0; |
491 | 490 | ||
492 | while (processedLength < req.AssetInf.Data.Length) | 491 | while (processedLength < req.AssetInf.Data.Length) |
493 | { | 492 | { |
494 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | 493 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); |
495 | TransferPacket.TransferData.Packet = packetNumber; | 494 | TransferPacket.TransferData.Packet = packetNumber; |
496 | TransferPacket.TransferData.ChannelType = 2; | 495 | TransferPacket.TransferData.ChannelType = 2; |
497 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | 496 | TransferPacket.TransferData.TransferID = req.TransferRequestID; |
498 | 497 | ||
499 | int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); | 498 | int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); |
500 | byte[] chunk = new byte[chunkSize]; | 499 | byte[] chunk = new byte[chunkSize]; |
501 | Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); | 500 | Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); |
502 | 501 | ||
503 | TransferPacket.TransferData.Data = chunk; | 502 | TransferPacket.TransferData.Data = chunk; |
504 | 503 | ||
505 | // 0 indicates more packets to come, 1 indicates last packet | 504 | // 0 indicates more packets to come, 1 indicates last packet |
506 | if (req.AssetInf.Data.Length - processedLength > maxChunkSize) | 505 | if (req.AssetInf.Data.Length - processedLength > maxChunkSize) |
507 | { | 506 | { |
@@ -510,10 +509,10 @@ namespace OpenSim.Framework.Communications.Cache | |||
510 | else | 509 | else |
511 | { | 510 | { |
512 | TransferPacket.TransferData.Status = 1; | 511 | TransferPacket.TransferData.Status = 1; |
513 | } | 512 | } |
514 | 513 | ||
515 | req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | 514 | req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); |
516 | 515 | ||
517 | processedLength += chunkSize; | 516 | processedLength += chunkSize; |
518 | packetNumber++; | 517 | packetNumber++; |
519 | } | 518 | } |
@@ -609,4 +608,4 @@ namespace OpenSim.Framework.Communications.Cache | |||
609 | } | 608 | } |
610 | } | 609 | } |
611 | } | 610 | } |
612 | } | 611 | } \ No newline at end of file |