From 73b7f3c9f4daa094921caa582f219f34c0c72541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 13 Sep 2016 00:59:22 +0200 Subject: [PATCH] Fix corrupted tcp stream when pinging while sending packets Don't push network packets to the front of the queue if the frist packet is only partially transmitted. They are now inserted at the second position instead. --- src/network/NetworkConnection.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/network/NetworkConnection.cpp b/src/network/NetworkConnection.cpp index 5844f4bf53..4263361ce1 100644 --- a/src/network/NetworkConnection.cpp +++ b/src/network/NetworkConnection.cpp @@ -121,7 +121,17 @@ void NetworkConnection::QueuePacket(std::unique_ptr packet, bool packet->size = (uint16)packet->data->size(); if (front) { - _outboundPackets.push_front(std::move(packet)); + // If the first packet was already partially sent add new packet to second position + if (_outboundPackets.size() > 0 && _outboundPackets.front()->transferred > 0) + { + auto it = _outboundPackets.begin(); + it++; // Second position + _outboundPackets.insert(it, std::move(packet)); + } + else + { + _outboundPackets.push_front(std::move(packet)); + } } else {