From cb29926e3cefedd9bea3c26b1b7f079c8209f6fa Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 18 Jun 2008 23:04:15 +0000 Subject: * Refactors call to OutPacket out of AssetCache and into LLClientView --- .../Framework/Communications/Cache/AssetCache.cs | 85 +++++----------------- 1 file changed, 17 insertions(+), 68 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index a1d9c73..2c51160 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -612,80 +612,29 @@ namespace OpenSim.Framework.Communications.Cache int num = Math.Min(5, AssetRequests.Count); AssetRequest req; + AssetRequestToClient req2 = null; for (int i = 0; i < num; i++) { req = (AssetRequest)AssetRequests[i]; - //Console.WriteLine("sending asset " + req.RequestAssetID); - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - if (req.AssetRequestSource == 2) + if (req2 == null) { - Transfer.TransferInfo.Params = new byte[20]; - Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int)req.AssetInf.Type; - Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); + req2 = new AssetRequestToClient(); } - else if (req.AssetRequestSource == 3) - { - Transfer.TransferInfo.Params = req.Params; - // Transfer.TransferInfo.Params = new byte[100]; - //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); - } - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; - Transfer.TransferInfo.TransferID = req.TransferRequestID; - Transfer.Header.Zerocoded = true; - req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); + // Trying to limit memory usage by only creating AssetRequestToClient if needed + //req2 = new AssetRequestToClient(); + req2.AssetInf = (AssetBase)req.AssetInf; + req2.AssetRequestSource = req.AssetRequestSource; + req2.DataPointer = req.DataPointer; + req2.DiscardLevel = req.DiscardLevel; + req2.ImageInfo = (AssetBase)req.ImageInfo; + req2.IsTextureRequest = req.IsTextureRequest; + req2.NumPackets = req.NumPackets; + req2.PacketCounter = req.PacketCounter; + req2.Params = req.Params; + req2.RequestAssetID = req.RequestAssetID; + req2.TransferRequestID = req.TransferRequestID; + req.RequestUser.SendAsset(req2); - if (req.NumPackets == 1) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - TransferPacket.TransferData.Data = req.AssetInf.Data; - TransferPacket.TransferData.Status = 1; - TransferPacket.Header.Zerocoded = true; - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - } - else - { - int processedLength = 0; - // libsecondlife hardcodes 1500 as the maximum data chunk size - int maxChunkSize = 1250; - int packetNumber = 0; - - while (processedLength < req.AssetInf.Data.Length) - { - TransferPacketPacket 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[] chunk = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); - - TransferPacket.TransferData.Data = chunk; - - // 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; - } - TransferPacket.Header.Zerocoded = true; - req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - - processedLength += chunkSize; - packetNumber++; - } - } } //remove requests that have been completed -- cgit v1.1