From baded95e1f6418c81b58492d9ca3458907179e2d Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Thu, 29 May 2025 09:07:51 -0400 Subject: [PATCH] BUGFIX: correct issue where the pingTime configurable on the FNE could be greater then the maximum allowable timeout on the peers resulting in highly unstable configurations, the maximum allowable ping time is set to a hardcoded 60 second maximum; --- src/common/network/BaseNetwork.h | 2 ++ src/common/network/Network.cpp | 2 +- src/fne/HostFNE.cpp | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/network/BaseNetwork.h b/src/common/network/BaseNetwork.h index c89c7a01..ccb2092b 100644 --- a/src/common/network/BaseNetwork.h +++ b/src/common/network/BaseNetwork.h @@ -69,6 +69,8 @@ #define TAG_ANNOUNCE "ANNC" #define TAG_PEER_LINK "PRLNK" +#define MAX_PEER_PING_TIME 60U // 60 seconds + namespace network { // --------------------------------------------------------------------------- diff --git a/src/common/network/Network.cpp b/src/common/network/Network.cpp index 1770b3d4..7581c239 100644 --- a/src/common/network/Network.cpp +++ b/src/common/network/Network.cpp @@ -52,7 +52,7 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort, m_tidLookup(nullptr), m_salt(nullptr), m_retryTimer(1000U, 10U), - m_timeoutTimer(1000U, 60U), + m_timeoutTimer(1000U, MAX_PEER_PING_TIME), m_pktSeq(0U), m_loginStreamId(0U), m_metadata(nullptr), diff --git a/src/fne/HostFNE.cpp b/src/fne/HostFNE.cpp index 674bf52e..dabcfb29 100644 --- a/src/fne/HostFNE.cpp +++ b/src/fne/HostFNE.cpp @@ -337,6 +337,11 @@ bool HostFNE::readParams() m_pingTime = 5U; } + if (m_pingTime > MAX_PEER_PING_TIME - 1U) { + LogWarning(LOG_HOST, "Peer ping time is set to %u seconds, this is beyond the allowable maximum of %u seconds. Defaulting.", m_pingTime, MAX_PEER_PING_TIME); + m_pingTime = MAX_PEER_PING_TIME - 1U; + } + if (m_maxMissedPings == 0U) { m_maxMissedPings = 5U; }