diff options
author | Teravus Ovares | 2007-12-14 00:54:12 +0000 |
---|---|---|
committer | Teravus Ovares | 2007-12-14 00:54:12 +0000 |
commit | fef8c77a8a40f150b11380cb2fd64c9f629cb42b (patch) | |
tree | 4a7cb19b4c8d88af7ea01874df15064568dd7fb3 /OpenSim/Framework/Communications | |
parent | * Added Active(physical) object count to the SimStatsReporter (diff) | |
download | opensim-SC_OLD-fef8c77a8a40f150b11380cb2fd64c9f629cb42b.zip opensim-SC_OLD-fef8c77a8a40f150b11380cb2fd64c9f629cb42b.tar.gz opensim-SC_OLD-fef8c77a8a40f150b11380cb2fd64c9f629cb42b.tar.bz2 opensim-SC_OLD-fef8c77a8a40f150b11380cb2fd64c9f629cb42b.tar.xz |
patch from justincc for Mantis #163 - Opening a script in inventory longer than 1500characters can cause looping crash.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index c164f0c..3edc7eb 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -94,8 +94,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
94 | Thread.Sleep(500); | 94 | Thread.Sleep(500); |
95 | } | 95 | } |
96 | catch (Exception e) | 96 | catch (Exception e) |
97 | { | 97 | { |
98 | System.Console.WriteLine(e.Message + " : " + e.StackTrace); | 98 | m_log.Error("ASSETCACHE", e.ToString()); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | } | 101 | } |
@@ -492,15 +492,40 @@ namespace OpenSim.Framework.Communications.Cache | |||
492 | TransferPacket.TransferData.Status = 0; | 492 | TransferPacket.TransferData.Status = 0; |
493 | req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | 493 | req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); |
494 | 494 | ||
495 | TransferPacket = new TransferPacketPacket(); | 495 | int processedLength = 1000; |
496 | TransferPacket.TransferData.Packet = 1; | 496 | // libsecondlife tells us that the largest allowable chunk is 1500 bytes |
497 | TransferPacket.TransferData.ChannelType = 2; | 497 | // XXX Fix up this magic number (and others)! |
498 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | 498 | int maxChunkSize = 1500; |
499 | byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)]; | 499 | int packetNumber = 1; |
500 | Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); | 500 | |
501 | TransferPacket.TransferData.Data = chunk1; | 501 | while (processedLength < req.AssetInf.Data.Length) |
502 | TransferPacket.TransferData.Status = 1; | 502 | { |
503 | req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | 503 | TransferPacket = new TransferPacketPacket(); |
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 | } | ||
504 | } | 529 | } |
505 | } | 530 | } |
506 | } | 531 | } |