From 58f9830a94e1456b08d98cd37e661b1531b8a9bf Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 9 Oct 2015 10:04:35 -0700 Subject: [PATCH] fix for re-send timeout in SendQueue --- libraries/networking/src/udt/Connection.cpp | 1 + libraries/networking/src/udt/SendQueue.cpp | 3 ++- libraries/networking/src/udt/SendQueue.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index 96d73676f0..639b2990ec 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -91,6 +91,7 @@ SendQueue& Connection::getSendQueue() { // set defaults on the send queue from our congestion control object and estimatedTimeout() _sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod); + _sendQueue->setSyncInterval(_synInterval); _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 01175d0a94..fd11b0f41e 100644 --- a/libraries/networking/src/udt/SendQueue.cpp +++ b/libraries/networking/src/udt/SendQueue.cpp @@ -439,7 +439,8 @@ bool SendQueue::isInactive(bool sentAPacket) { } else { // We think the client is still waiting for data (based on the sequence number gap) // Let's wait either for a response from the client or until the estimated timeout - auto waitDuration = std::chrono::microseconds(_estimatedTimeout); + // (plus the sync interval to allow the client to respond) has elapsed + auto waitDuration = std::chrono::microseconds(_estimatedTimeout + _syncInterval); // use our condition_variable_any to wait auto cvStatus = _emptyCondition.wait_for(locker, waitDuration); diff --git a/libraries/networking/src/udt/SendQueue.h b/libraries/networking/src/udt/SendQueue.h index 96de12a971..3fe4006139 100644 --- a/libraries/networking/src/udt/SendQueue.h +++ b/libraries/networking/src/udt/SendQueue.h @@ -63,6 +63,7 @@ public: void setPacketSendPeriod(int newPeriod) { _packetSendPeriod = newPeriod; } void setEstimatedTimeout(int estimatedTimeout) { _estimatedTimeout = estimatedTimeout; } + void setSyncInterval(int syncInterval) { _syncInterval = syncInterval; } public slots: void stop(); @@ -114,6 +115,7 @@ private: std::atomic _state { State::NotStarted }; std::atomic _estimatedTimeout { 0 }; // Estimated timeout, set from CC + std::atomic _syncInterval { udt::DEFAULT_SYN_INTERVAL_USECS }; // Sync interval, set from CC std::atomic _timeoutExpiryCount { 0 }; // The number of times the timeout has expired without response from client std::atomic _lastReceiverResponse { 0 }; // Timestamp for the last time we got new data from the receiver (ACK/NAK)