mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
ensure a handshake goes out the first time
This commit is contained in:
parent
a27e0e7cc7
commit
6a186ad1fe
1 changed files with 5 additions and 11 deletions
|
@ -279,17 +279,13 @@ void SendQueue::run() {
|
||||||
if (!_hasReceivedHandshakeACK) {
|
if (!_hasReceivedHandshakeACK) {
|
||||||
// we haven't received a handshake ACK from the client
|
// we haven't received a handshake ACK from the client
|
||||||
// if it has been at least 100ms since we last sent a handshake, send another now
|
// if it has been at least 100ms since we last sent a handshake, send another now
|
||||||
|
|
||||||
// hold the time of last send in a static
|
|
||||||
static auto lastSendHandshake = p_high_resolution_clock::time_point().min();
|
|
||||||
|
|
||||||
static const auto HANDSHAKE_RESEND_INTERVAL_MS = std::chrono::milliseconds(100);
|
static const auto HANDSHAKE_RESEND_INTERVAL_MS = std::chrono::milliseconds(100);
|
||||||
|
|
||||||
// calculation the duration since the last handshake send
|
// hold the time of last send in a static
|
||||||
auto sinceLastHandshake = std::chrono::duration_cast<std::chrono::milliseconds>(p_high_resolution_clock::now()
|
static auto lastSendHandshake = p_high_resolution_clock::now() - HANDSHAKE_RESEND_INTERVAL_MS;
|
||||||
- lastSendHandshake);
|
|
||||||
|
|
||||||
if (sinceLastHandshake >= HANDSHAKE_RESEND_INTERVAL_MS) {
|
if (p_high_resolution_clock::now() - lastSendHandshake >= HANDSHAKE_RESEND_INTERVAL_MS) {
|
||||||
|
|
||||||
// it has been long enough since last handshake, send another
|
// it has been long enough since last handshake, send another
|
||||||
static auto handshakePacket = ControlPacket::create(ControlPacket::Handshake, 0);
|
static auto handshakePacket = ControlPacket::create(ControlPacket::Handshake, 0);
|
||||||
|
@ -299,9 +295,7 @@ void SendQueue::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we wait for the ACK or the re-send interval to expire
|
// we wait for the ACK or the re-send interval to expire
|
||||||
_handshakeACKCondition.wait_until(handshakeLock,
|
_handshakeACKCondition.wait_until(handshakeLock, p_high_resolution_clock::now() + HANDSHAKE_RESEND_INTERVAL_MS);
|
||||||
p_high_resolution_clock::now()
|
|
||||||
+ HANDSHAKE_RESEND_INTERVAL_MS);
|
|
||||||
|
|
||||||
// Once we're here we've either received the handshake ACK or it's going to be time to re-send a handshake.
|
// Once we're here we've either received the handshake ACK or it's going to be time to re-send a handshake.
|
||||||
// Either way let's continue processing - no packets will be sent if no handshake ACK has been received.
|
// Either way let's continue processing - no packets will be sent if no handshake ACK has been received.
|
||||||
|
|
Loading…
Reference in a new issue