patch from justincc for Mantis #163 - Opening a script in inventory longer than 1500characters can cause looping crash.
parent
7fdfeb5830
commit
fef8c77a8a
|
@ -94,8 +94,8 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
System.Console.WriteLine(e.Message + " : " + e.StackTrace);
|
m_log.Error("ASSETCACHE", e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,15 +492,40 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
TransferPacket.TransferData.Status = 0;
|
TransferPacket.TransferData.Status = 0;
|
||||||
req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
|
req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
|
||||||
|
|
||||||
TransferPacket = new TransferPacketPacket();
|
int processedLength = 1000;
|
||||||
TransferPacket.TransferData.Packet = 1;
|
// libsecondlife tells us that the largest allowable chunk is 1500 bytes
|
||||||
TransferPacket.TransferData.ChannelType = 2;
|
// XXX Fix up this magic number (and others)!
|
||||||
TransferPacket.TransferData.TransferID = req.TransferRequestID;
|
int maxChunkSize = 1500;
|
||||||
byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)];
|
int packetNumber = 1;
|
||||||
Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
|
|
||||||
TransferPacket.TransferData.Data = chunk1;
|
while (processedLength < req.AssetInf.Data.Length)
|
||||||
TransferPacket.TransferData.Status = 1;
|
{
|
||||||
req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
|
TransferPacket = new TransferPacketPacket();
|
||||||
|
TransferPacket.TransferData.Packet = packetNumber;
|
||||||
|
TransferPacket.TransferData.ChannelType = 2;
|
||||||
|
TransferPacket.TransferData.TransferID = req.TransferRequestID;
|
||||||
|
|
||||||
|
int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
|
||||||
|
byte[] chunk1 = new byte[chunkSize];
|
||||||
|
Array.Copy(req.AssetInf.Data, processedLength, chunk1, 0, chunk1.Length);
|
||||||
|
|
||||||
|
TransferPacket.TransferData.Data = chunk1;
|
||||||
|
|
||||||
|
// 0 indicates more packets to come, 1 indicates last packet
|
||||||
|
if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
|
||||||
|
{
|
||||||
|
TransferPacket.TransferData.Status = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TransferPacket.TransferData.Status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
|
||||||
|
|
||||||
|
processedLength += chunkSize;
|
||||||
|
packetNumber++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue