Skip to content

Commit 7d800ef

Browse files
authored
Don't set m_LastPacketTimestamp on handshake when we are connected (#513)
If another tracker is trying to find the server, they will send the handshake packet to the whole network, which prevents us from realising if the connection to server has timed out.
1 parent 12f4b22 commit 7d800ef

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/network/connection.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@ void Connection::update() {
664664
return;
665665
}
666666

667-
m_LastPacketTimestamp = millis();
668667
int len = m_UDP.read(m_Packet, sizeof(m_Packet));
669668

670669
#ifdef DEBUG_NETWORK
@@ -679,6 +678,12 @@ void Connection::update() {
679678
(void)packetSize;
680679
#endif
681680

681+
if (static_cast<ReceivePacketType>(m_Packet[3]) == ReceivePacketType::Handshake) {
682+
m_Logger.warn("Handshake received again, ignoring");
683+
return;
684+
}
685+
686+
m_LastPacketTimestamp = millis();
682687
switch (static_cast<ReceivePacketType>(m_Packet[3])) {
683688
case ReceivePacketType::HeartBeat:
684689
sendHeartbeat();
@@ -688,8 +693,7 @@ void Connection::update() {
688693
break;
689694

690695
case ReceivePacketType::Handshake:
691-
// Assume handshake successful
692-
m_Logger.warn("Handshake received again, ignoring");
696+
// handled above
693697
break;
694698

695699
case ReceivePacketType::Command:

0 commit comments

Comments
 (0)