aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/AssetCache.cs
diff options
context:
space:
mode:
authorCharles Krinke2007-12-14 20:09:44 +0000
committerCharles Krinke2007-12-14 20:09:44 +0000
commit4e7763f8def82f09fa7d1b2214ab337a3c4e1a90 (patch)
treec99e41717b575dae010cff7c42ea81cadb33b15f /OpenSim/Framework/Communications/Cache/AssetCache.cs
parentpluging away, setting up storage manager (diff)
downloadopensim-SC_OLD-4e7763f8def82f09fa7d1b2214ab337a3c4e1a90.zip
opensim-SC_OLD-4e7763f8def82f09fa7d1b2214ab337a3c4e1a90.tar.gz
opensim-SC_OLD-4e7763f8def82f09fa7d1b2214ab337a3c4e1a90.tar.bz2
opensim-SC_OLD-4e7763f8def82f09fa7d1b2214ab337a3c4e1a90.tar.xz
Thank you Justin for:
0000188: Clean up of some AssetCache.ProcessAssetQueue() code
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs79
1 files changed, 27 insertions, 52 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 3edc7eb..abaea23 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -469,63 +469,38 @@ namespace OpenSim.Framework.Communications.Cache
469 } 469 }
470 else 470 else
471 { 471 {
472 //more than one packet so split file up , for now it can't be bigger than 2000 bytes 472 int processedLength = 0;
473 TransferPacketPacket TransferPacket = new TransferPacketPacket(); 473 // libsecondlife hardcodes 1500 as the maximum data chunk size
474 TransferPacket.TransferData.Packet = 0; 474 int maxChunkSize = 1500;
475 TransferPacket.TransferData.ChannelType = 2; 475 int packetNumber = 0;
476 TransferPacket.TransferData.TransferID = req.TransferRequestID; 476
477 byte[] chunk = null; 477 while (processedLength < req.AssetInf.Data.Length)
478 if (req.AssetInf.Data.Length <= 1000)
479 { 478 {
480 chunk = new byte[req.AssetInf.Data.Length]; 479 TransferPacketPacket TransferPacket = new TransferPacketPacket();
481 Array.Copy(req.AssetInf.Data, chunk, req.AssetInf.Data.Length); 480 TransferPacket.TransferData.Packet = packetNumber;
482 TransferPacket.TransferData.Data = chunk; 481 TransferPacket.TransferData.ChannelType = 2;
483 TransferPacket.TransferData.Status = 1; 482 TransferPacket.TransferData.TransferID = req.TransferRequestID;
484 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); 483
485 } 484 int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
486 else 485 byte[] chunk = new byte[chunkSize];
487 { 486 Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
488 chunk = new byte[1000]; 487
489 Array.Copy(req.AssetInf.Data, chunk, 1000);
490
491 TransferPacket.TransferData.Data = chunk; 488 TransferPacket.TransferData.Data = chunk;
492 TransferPacket.TransferData.Status = 0;
493 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
494
495 int processedLength = 1000;
496 // libsecondlife tells us that the largest allowable chunk is 1500 bytes
497 // XXX Fix up this magic number (and others)!
498 int maxChunkSize = 1500;
499 int packetNumber = 1;
500 489
501 while (processedLength < req.AssetInf.Data.Length) 490 // 0 indicates more packets to come, 1 indicates last packet
491 if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
502 { 492 {
503 TransferPacket = new TransferPacketPacket(); 493 TransferPacket.TransferData.Status = 0;
504 TransferPacket.TransferData.Packet = packetNumber;
505 TransferPacket.TransferData.ChannelType = 2;
506 TransferPacket.TransferData.TransferID = req.TransferRequestID;
507
508 int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
509 byte[] chunk1 = new byte[chunkSize];
510 Array.Copy(req.AssetInf.Data, processedLength, chunk1, 0, chunk1.Length);
511
512 TransferPacket.TransferData.Data = chunk1;
513
514 // 0 indicates more packets to come, 1 indicates last packet
515 if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
516 {
517 TransferPacket.TransferData.Status = 0;
518 }
519 else
520 {
521 TransferPacket.TransferData.Status = 1;
522 }
523
524 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
525
526 processedLength += chunkSize;
527 packetNumber++;
528 } 494 }
495 else
496 {
497 TransferPacket.TransferData.Status = 1;
498 }
499
500 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
501
502 processedLength += chunkSize;
503 packetNumber++;
529 } 504 }
530 } 505 }
531 } 506 }