mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:23:33 +02:00
Set minimum timeout for retransmits
This commit is contained in:
parent
719919d3fd
commit
0d14e0bcf7
2 changed files with 8 additions and 6 deletions
|
@ -61,6 +61,9 @@ private:
|
||||||
Mutex2& _mutex2;
|
Mutex2& _mutex2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const microseconds SendQueue::MAXIMUM_ESTIMATED_TIMEOUT = seconds(5);
|
||||||
|
const microseconds SendQueue::MINIMUM_ESTIMATED_TIMEOUT = milliseconds(10);
|
||||||
|
|
||||||
std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, HifiSockAddr destination, SequenceNumber currentSequenceNumber,
|
std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, HifiSockAddr destination, SequenceNumber currentSequenceNumber,
|
||||||
MessageNumber currentMessageNumber, bool hasReceivedHandshakeACK) {
|
MessageNumber currentMessageNumber, bool hasReceivedHandshakeACK) {
|
||||||
Q_ASSERT_X(socket, "SendQueue::create", "Must be called with a valid Socket*");
|
Q_ASSERT_X(socket, "SendQueue::create", "Must be called with a valid Socket*");
|
||||||
|
@ -505,12 +508,8 @@ bool SendQueue::isInactive(bool attemptedToSendPacket) {
|
||||||
|
|
||||||
auto estimatedTimeout = std::chrono::microseconds(_estimatedTimeout);
|
auto estimatedTimeout = std::chrono::microseconds(_estimatedTimeout);
|
||||||
|
|
||||||
// cap our maximum estimated timeout to the already unreasonable 5 seconds
|
// Clamp timeout beween 10 ms and 5 s
|
||||||
const auto MAXIMUM_ESTIMATED_TIMEOUT = std::chrono::seconds(5);
|
estimatedTimeout = std::min(MAXIMUM_ESTIMATED_TIMEOUT, std::max(MINIMUM_ESTIMATED_TIMEOUT, estimatedTimeout));
|
||||||
|
|
||||||
if (estimatedTimeout > MAXIMUM_ESTIMATED_TIMEOUT) {
|
|
||||||
estimatedTimeout = MAXIMUM_ESTIMATED_TIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use our condition_variable_any to wait
|
// use our condition_variable_any to wait
|
||||||
auto cvStatus = _emptyCondition.wait_for(locker, estimatedTimeout);
|
auto cvStatus = _emptyCondition.wait_for(locker, estimatedTimeout);
|
||||||
|
|
|
@ -140,6 +140,9 @@ private:
|
||||||
std::condition_variable_any _emptyCondition;
|
std::condition_variable_any _emptyCondition;
|
||||||
|
|
||||||
std::chrono::high_resolution_clock::time_point _lastPacketSentAt;
|
std::chrono::high_resolution_clock::time_point _lastPacketSentAt;
|
||||||
|
|
||||||
|
static const std::chrono::microseconds MAXIMUM_ESTIMATED_TIMEOUT;
|
||||||
|
static const std::chrono::microseconds MINIMUM_ESTIMATED_TIMEOUT;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue