From 539108dd454a13cfb8ed345b2a47683aca42cfac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 28 Aug 2015 09:26:32 -0700 Subject: [PATCH] repairs for new timeout code --- libraries/networking/src/udt/Connection.cpp | 3 ++- libraries/networking/src/udt/SendQueue.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index 74ad707b11..93c13874ea 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -78,8 +78,9 @@ SendQueue& Connection::getSendQueue() { QObject::connect(_sendQueue.get(), &SendQueue::packetRetransmitted, this, &Connection::recordRetransmission); QObject::connect(_sendQueue.get(), &SendQueue::queueInactive, this, &Connection::queueInactive); - // set defaults on the send queue from our congestion control object + // set defaults on the send queue from our congestion control object and estimatedTimeout() _sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod); + _sendQueue->setEstimatedTimeout(estimatedTimeout()); _sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize)); } diff --git a/libraries/networking/src/udt/SendQueue.cpp b/libraries/networking/src/udt/SendQueue.cpp index 7db24a63a3..d627937761 100644 --- a/libraries/networking/src/udt/SendQueue.cpp +++ b/libraries/networking/src/udt/SendQueue.cpp @@ -361,7 +361,8 @@ void SendQueue::run() { if (cvStatus == std::cv_status::timeout) { qDebug() << "SendQueue to" << _destination << "has been empty for" << std::chrono::duration_cast(EMPTY_QUEUES_INACTIVE_TIMEOUT_US).count() - << "and receiver has ACKed all packets. The queue is considered inactive and will be stopped"; + << "seconds and receiver has ACKed all packets." + << "The queue is considered inactive and will be stopped."; // this queue is inactive - emit that signal and stop the while emit queueInactive(); @@ -379,9 +380,13 @@ void SendQueue::run() { // increase the number of timeouts ++_timeoutExpiryCount; - // Add all of the packets above the last received ACKed sequence number to the loss list - // Note that thanks to the DoubleLock we have the _naksLock right now - _naks.append(SequenceNumber(_lastACKSequenceNumber) + 1, _currentSequenceNumber); + if (SequenceNumber(_lastACKSequenceNumber) < _currentSequenceNumber) { + // after a timeout if we still have sent packets that the client hasn't ACKed we + // add them to the loss list + + // Note that thanks to the DoubleLock we have the _naksLock right now + _naks.append(SequenceNumber(_lastACKSequenceNumber) + 1, _currentSequenceNumber); + } } // we have the double lock again - Make sure to unlock it