aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs47
1 files changed, 27 insertions, 20 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 3c4fa72..41e41e4 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -513,6 +513,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
513 byte flags = buffer.Data[0]; 513 byte flags = buffer.Data[0];
514 bool isResend = (flags & Helpers.MSG_RESENT) != 0; 514 bool isResend = (flags & Helpers.MSG_RESENT) != 0;
515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; 515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
516 bool isZerocoded = (flags & Helpers.MSG_ZEROCODED) != 0;
516 LLUDPClient udpClient = outgoingPacket.Client; 517 LLUDPClient udpClient = outgoingPacket.Client;
517 518
518 if (!udpClient.IsConnected) 519 if (!udpClient.IsConnected)
@@ -522,23 +523,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
522 523
523 int dataLength = buffer.DataLength; 524 int dataLength = buffer.DataLength;
524 525
525 // Keep appending ACKs until there is no room left in the buffer or there are 526 // NOTE: I'm seeing problems with some viewers when ACKs are appended to zerocoded packets so I've disabled that here
526 // no more ACKs to append 527 if (!isZerocoded)
527 uint ackCount = 0;
528 uint ack;
529 while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
530 { 528 {
531 Utils.UIntToBytesBig(ack, buffer.Data, dataLength); 529 // Keep appending ACKs until there is no room left in the buffer or there are
532 dataLength += 4; 530 // no more ACKs to append
533 ++ackCount; 531 uint ackCount = 0;
534 } 532 uint ack;
533 while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
534 {
535 Utils.UIntToBytesBig(ack, buffer.Data, dataLength);
536 dataLength += 4;
537 ++ackCount;
538 }
535 539
536 if (ackCount > 0) 540 if (ackCount > 0)
537 { 541 {
538 // Set the last byte of the packet equal to the number of appended ACKs 542 // Set the last byte of the packet equal to the number of appended ACKs
539 buffer.Data[dataLength++] = (byte)ackCount; 543 buffer.Data[dataLength++] = (byte)ackCount;
540 // Set the appended ACKs flag on this packet 544 // Set the appended ACKs flag on this packet
541 buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS); 545 buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS);
546 }
542 } 547 }
543 548
544 buffer.DataLength = dataLength; 549 buffer.DataLength = dataLength;
@@ -596,15 +601,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
596 } 601 }
597 catch (MalformedDataException) 602 catch (MalformedDataException)
598 { 603 {
599 m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse packet from {0}:\n{1}",
600 buffer.RemoteEndPoint, Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
601 } 604 }
602 605
603 // Fail-safe check 606 // Fail-safe check
604 if (packet == null) 607 if (packet == null)
605 { 608 {
606 m_log.Warn("[LLUDPSERVER]: Couldn't build a message from incoming data " + buffer.DataLength + 609 m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse {0} byte packet from {1}:",
607 " bytes long from " + buffer.RemoteEndPoint); 610 buffer.DataLength, buffer.RemoteEndPoint);
611 m_log.Error(Utils.BytesToHexString(buffer.Data, buffer.DataLength, null));
608 return; 612 return;
609 } 613 }
610 614
@@ -919,7 +923,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
919 // Remove this client from the scene 923 // Remove this client from the scene
920 IClientAPI client; 924 IClientAPI client;
921 if (m_scene.TryGetClient(udpClient.AgentID, out client)) 925 if (m_scene.TryGetClient(udpClient.AgentID, out client))
926 {
927 client.IsLoggingOut = true;
922 client.Close(); 928 client.Close();
929 }
923 } 930 }
924 931
925 private void IncomingPacketHandler() 932 private void IncomingPacketHandler()
@@ -1018,7 +1025,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1018 1025
1019 // Handle outgoing packets, resends, acknowledgements, and pings for each 1026 // Handle outgoing packets, resends, acknowledgements, and pings for each
1020 // client. m_packetSent will be set to true if a packet is sent 1027 // client. m_packetSent will be set to true if a packet is sent
1021 m_scene.ForEachClient(clientPacketHandler, false); 1028 m_scene.ForEachClient(clientPacketHandler);
1022 1029
1023 // If nothing was sent, sleep for the minimum amount of time before a 1030 // If nothing was sent, sleep for the minimum amount of time before a
1024 // token bucket could get more tokens 1031 // token bucket could get more tokens