reduce some useless array copies
							parent
							
								
									41e2379f97
								
							
						
					
					
						commit
						9ff7601214
					
				|  | @ -1235,7 +1235,8 @@ namespace OpenSim.Framework | ||||||
|         /// <param name="node"></param> |         /// <param name="node"></param> | ||||||
|         void SendBulkUpdateInventory(InventoryNodeBase node); |         void SendBulkUpdateInventory(InventoryNodeBase node); | ||||||
| 
 | 
 | ||||||
|         void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory); |         void SendXferPacket(ulong xferID, uint packet, | ||||||
|  |                 byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory); | ||||||
| 
 | 
 | ||||||
|         void SendAbortXferPacket(ulong xferID); |         void SendAbortXferPacket(ulong xferID); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2886,7 +2886,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | ||||||
|                 18 // ID (high frequency bigendian) |                 18 // ID (high frequency bigendian) | ||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|         public void SendXferPacket(ulong xferID, uint packet, byte[] payload, bool isTaskInventory) |         public void SendXferPacket(ulong xferID, uint packet, | ||||||
|  |                 byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory) | ||||||
|         { |         { | ||||||
|             UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); |             UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); | ||||||
|             byte[] data = buf.Data; |             byte[] data = buf.Data; | ||||||
|  | @ -2896,7 +2897,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | ||||||
| 
 | 
 | ||||||
|             Utils.UInt64ToBytesSafepos(xferID, data, 7); // 15 |             Utils.UInt64ToBytesSafepos(xferID, data, 7); // 15 | ||||||
|             Utils.UIntToBytesSafepos(packet, data, 15); // 19 |             Utils.UIntToBytesSafepos(packet, data, 15); // 19 | ||||||
|             int len = payload.Length; | 
 | ||||||
|  |             int len = XferDatapktLen; | ||||||
|  |             if (XferDataOffset == 0) // first packet needs to send the total xfer data len | ||||||
|  |                 len += 4; | ||||||
|  | 
 | ||||||
|             if (len > LLUDPServer.MAXPAYLOAD) // should never happen |             if (len > LLUDPServer.MAXPAYLOAD) // should never happen | ||||||
|                 len = LLUDPServer.MAXPAYLOAD; |                 len = LLUDPServer.MAXPAYLOAD; | ||||||
|             if (len == 0) |             if (len == 0) | ||||||
|  | @ -2908,7 +2913,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | ||||||
|             { |             { | ||||||
|                 data[19] = (byte)len; |                 data[19] = (byte)len; | ||||||
|                 data[20] = (byte)(len >> 8); |                 data[20] = (byte)(len >> 8); | ||||||
|                 Buffer.BlockCopy(payload, 0, data, 21, len); |                 if(XferDataOffset == 0) | ||||||
|  |                 { | ||||||
|  |                     // need to send total xfer data len | ||||||
|  |                     Utils.IntToBytesSafepos(XferData.Length, data, 21); | ||||||
|  |                     if (XferDatapktLen > 0) | ||||||
|  |                         Buffer.BlockCopy(XferData, XferDataOffset, data, 25, XferDatapktLen); | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     Buffer.BlockCopy(XferData, XferDataOffset, data, 21, XferDatapktLen); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             buf.DataLength = 21 + len; |             buf.DataLength = 21 + len; | ||||||
|  |  | ||||||
|  | @ -272,9 +272,9 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | ||||||
|                         if (!Transfers.ContainsKey(xferID)) |                         if (!Transfers.ContainsKey(xferID)) | ||||||
|                         { |                         { | ||||||
|                             byte[] fileData = NewFiles[fileName].Data; |                             byte[] fileData = NewFiles[fileName].Data; | ||||||
|                             int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Asset) >> 11; |                             int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10; | ||||||
|                             if(Transfers.Count > 1) |                             burstSize = burstSize * (remoteClient.PingTimeMS + 50); | ||||||
|                                 burstSize /= Transfers.Count; |                             burstSize >>= 9; //  ping is ms, 2 round trips | ||||||
|                             XferDownLoad transaction = |                             XferDownLoad transaction = | ||||||
|                                 new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); |                                 new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize); | ||||||
| 
 | 
 | ||||||
|  | @ -332,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | ||||||
|             private int lastBytes; |             private int lastBytes; | ||||||
|             private int lastSentPacket; |             private int lastSentPacket; | ||||||
|             private int lastAckPacket; |             private int lastAckPacket; | ||||||
|             private int burstSize; |             private int burstSize; // additional packets, so can be zero | ||||||
|             private int retries = 0; |             private int retries = 0; | ||||||
| 
 | 
 | ||||||
|             public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client, int burstsz) |             public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client, int burstsz) | ||||||
|  | @ -352,7 +352,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | ||||||
|             { |             { | ||||||
|                 if(!isDeleted) |                 if(!isDeleted) | ||||||
|                 { |                 { | ||||||
|                     Data = new byte[0]; |                     Data = null; | ||||||
|                     isDeleted = true; |                     isDeleted = true; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  | @ -381,7 +381,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | ||||||
|                             lastBytes = 1024; |                             lastBytes = 1024; | ||||||
|                             LastPacket--; |                             LastPacket--; | ||||||
|                         } |                         } | ||||||
| 
 |  | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     lastAckPacket = -1; |                     lastAckPacket = -1; | ||||||
|  | @ -422,20 +421,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | ||||||
|                     pktid = (uint)pkt; |                     pktid = (uint)pkt; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 byte[] transferData; |                 Client.SendXferPacket(XferID, pktid, Data, pkt << 10, pktsize, true); | ||||||
|                 if(pkt == 0) |  | ||||||
|                 { |  | ||||||
|                     transferData = new byte[pktsize + 4]; |  | ||||||
|                     Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); |  | ||||||
|                     Array.Copy(Data, 0, transferData, 4, pktsize); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     transferData = new byte[pktsize]; |  | ||||||
|                     Array.Copy(Data, pkt << 10, transferData, 0, pktsize); |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 Client.SendXferPacket(XferID, pktid, transferData, false); |  | ||||||
| 
 | 
 | ||||||
|                 lastSentPacket = pkt; |                 lastSentPacket = pkt; | ||||||
|                 lastsendTimeMS = now; |                 lastsendTimeMS = now; | ||||||
|  |  | ||||||
|  | @ -1157,7 +1157,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) |         public void SendXferPacket(ulong xferID, uint packet,  | ||||||
|  |                 byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory) | ||||||
|         { |         { | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -868,9 +868,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) |         public virtual void SendXferPacket(ulong xferID, uint packet, | ||||||
|  |                 byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         public virtual void SendAbortXferPacket(ulong xferID) |         public virtual void SendAbortXferPacket(ulong xferID) | ||||||
|         { |         { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -819,7 +819,8 @@ namespace OpenSim.Tests.Common | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) |         public virtual void SendXferPacket(ulong xferID, uint packet, | ||||||
|  |                 byte[] XferData, int XferDataOffset, int XferDatapktLen, bool isTaskInventory) | ||||||
|         { |         { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 UbitUmarov
						UbitUmarov