From bbed828aae254174b8530520a621966b044b6ecf Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 26 Jul 2023 00:57:05 -0500 Subject: [PATCH] Cap the retransmit timer at 1/5 of the max peer timeout This helps avoiding spurious disconnections in cases of large RTT variance --- protocol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/protocol.c b/protocol.c index 972d221..e0b27be 100644 --- a/protocol.c +++ b/protocol.c @@ -1381,6 +1381,7 @@ enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * even ++ peer -> packetsLost; roundTripTimeout = peer -> roundTripTime + 4 * ENET_MAX (1, peer -> roundTripTimeVariance); + roundTripTimeout = ENET_MIN (roundTripTimeout, peer->timeoutMaximum / 5); if (outgoingCommand -> sendAttempts < peer -> timeoutLimit) outgoingCommand -> roundTripTimeout = roundTripTimeout * ENET_MAX (1, outgoingCommand -> sendAttempts); else