diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index f2b8720..8bfab6a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -270,6 +270,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
270 | { | 270 | { |
271 | int dataLength = data.Length; | 271 | int dataLength = data.Length; |
272 | bool doZerocode = (data[0] & Helpers.MSG_ZEROCODED) != 0; | 272 | bool doZerocode = (data[0] & Helpers.MSG_ZEROCODED) != 0; |
273 | bool doCopy = true; | ||
273 | 274 | ||
274 | // Frequency analysis of outgoing packet sizes shows a large clump of packets at each end of the spectrum. | 275 | // Frequency analysis of outgoing packet sizes shows a large clump of packets at each end of the spectrum. |
275 | // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting | 276 | // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting |
@@ -282,7 +283,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
282 | // Zerocode if needed | 283 | // Zerocode if needed |
283 | if (doZerocode) | 284 | if (doZerocode) |
284 | { | 285 | { |
285 | try { dataLength = Helpers.ZeroEncode(data, dataLength, buffer.Data); } | 286 | try |
287 | { | ||
288 | dataLength = Helpers.ZeroEncode(data, dataLength, buffer.Data); | ||
289 | doCopy = false; | ||
290 | } | ||
286 | catch (IndexOutOfRangeException) | 291 | catch (IndexOutOfRangeException) |
287 | { | 292 | { |
288 | // The packet grew larger than the bufferSize while zerocoding. | 293 | // The packet grew larger than the bufferSize while zerocoding. |
@@ -291,18 +296,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
291 | m_log.Debug("[LLUDPSERVER]: Packet exceeded buffer size during zerocoding for " + type + ". DataLength=" + dataLength + | 296 | m_log.Debug("[LLUDPSERVER]: Packet exceeded buffer size during zerocoding for " + type + ". DataLength=" + dataLength + |
292 | " and BufferLength=" + buffer.Data.Length + ". Removing MSG_ZEROCODED flag"); | 297 | " and BufferLength=" + buffer.Data.Length + ". Removing MSG_ZEROCODED flag"); |
293 | data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED); | 298 | data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED); |
294 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | ||
295 | } | 299 | } |
296 | } | 300 | } |
297 | else | 301 | |
302 | // If the packet data wasn't already copied during zerocoding, copy it now | ||
303 | if (doCopy) | ||
298 | { | 304 | { |
299 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | 305 | if (dataLength <= buffer.Data.Length) |
306 | { | ||
307 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | ||
308 | } | ||
309 | else | ||
310 | { | ||
311 | m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" + | ||
312 | type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length + ". Dropping packet"); | ||
313 | return; | ||
314 | } | ||
300 | } | 315 | } |
316 | |||
301 | buffer.DataLength = dataLength; | 317 | buffer.DataLength = dataLength; |
302 | 318 | ||
303 | #region Queue or Send | 319 | #region Queue or Send |
304 | 320 | ||
305 | // Look up the UDPClient this is going to | ||
306 | OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); | 321 | OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); |
307 | 322 | ||
308 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) | 323 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) |