From db7f5724f7830ecb027f87b6181fc4ace1bab89b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 27 Oct 2016 21:50:29 -0700 Subject: [PATCH 1/2] output last seq number and last socket before readyRead sticks --- libraries/networking/src/udt/Socket.cpp | 9 +++++++++ libraries/networking/src/udt/Socket.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 43bd7dd973..bf2a3fe6d2 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -306,6 +306,11 @@ void Socket::checkForReadyReadBackup() { if (_udpSocket.hasPendingDatagrams()) { qCDebug(networking) << "Socket::checkForReadyReadBackup() detected blocked readyRead signal. Flushing pending datagrams."; + // so that birarda can possibly figure out how the heck we get into this state in the first place + // output the sequence number and socket address of the last processed packet + qCDebug(networking) << "Socket::checkForReadyReadyBackup() last sequence number" + << (uint32_t) _lastReceivedSequenceNumber << "from" << _lastPacketSockAddr; + // drop all of the pending datagrams on the floor while (_udpSocket.hasPendingDatagrams()) { _udpSocket.readDatagram(nullptr, 0); @@ -373,6 +378,10 @@ void Socket::readPendingDatagrams() { auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr); packet->setReceiveTime(receiveTime); + // save the sequence number and socket for this packet, in case this is the packet that sticks readyRead + _lastPacketSockAddr = senderSockAddr; + _lastReceivedSequenceNumber = packet->getSequenceNumber(); + // call our verification operator to see if this packet is verified if (!_packetFilterOperator || _packetFilterOperator(*packet)) { if (packet->isReliable()) { diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index a811d78958..24f0b8afaf 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -144,6 +144,9 @@ private: std::unique_ptr _ccFactory { new CongestionControlFactory() }; bool _shouldChangeSocketOptions { true }; + + SequenceNumber _lastReceivedSequenceNumber; + HifiSockAddr _lastPacketSockAddr; friend UDTTest; }; From 20f042a15a134455e36dbb837a8a465a432c1161 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 27 Oct 2016 22:10:32 -0700 Subject: [PATCH 2/2] add slightly more information to last packet debug in Socket --- libraries/networking/src/udt/Socket.cpp | 11 ++++++++--- libraries/networking/src/udt/Socket.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index bf2a3fe6d2..fbf2a1c86a 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -309,7 +309,9 @@ void Socket::checkForReadyReadBackup() { // so that birarda can possibly figure out how the heck we get into this state in the first place // output the sequence number and socket address of the last processed packet qCDebug(networking) << "Socket::checkForReadyReadyBackup() last sequence number" - << (uint32_t) _lastReceivedSequenceNumber << "from" << _lastPacketSockAddr; + << (uint32_t) _lastReceivedSequenceNumber << "from" << _lastPacketSockAddr << "-" + << _lastPacketSizeRead << "bytes"; + // drop all of the pending datagrams on the floor while (_udpSocket.hasPendingDatagrams()) { @@ -339,6 +341,10 @@ void Socket::readPendingDatagrams() { auto sizeRead = _udpSocket.readDatagram(buffer.get(), packetSizeWithHeader, senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer()); + // save information for this packet, in case it is the one that sticks readyRead + _lastPacketSizeRead = sizeRead; + _lastPacketSockAddr = senderSockAddr; + if (sizeRead <= 0) { // we either didn't pull anything for this packet or there was an error reading (this seems to trigger // on windows even if there's not a packet available) @@ -378,8 +384,7 @@ void Socket::readPendingDatagrams() { auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr); packet->setReceiveTime(receiveTime); - // save the sequence number and socket for this packet, in case this is the packet that sticks readyRead - _lastPacketSockAddr = senderSockAddr; + // save the sequence number in case this is the packet that sticks readyRead _lastReceivedSequenceNumber = packet->getSequenceNumber(); // call our verification operator to see if this packet is verified diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h index 24f0b8afaf..1919e00b41 100644 --- a/libraries/networking/src/udt/Socket.h +++ b/libraries/networking/src/udt/Socket.h @@ -145,6 +145,7 @@ private: bool _shouldChangeSocketOptions { true }; + int _lastPacketSizeRead { 0 }; SequenceNumber _lastReceivedSequenceNumber; HifiSockAddr _lastPacketSockAddr;