From 96802e90ccb4005b22387c8057364394a58e6c82 Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Tue, 6 Jun 2023 17:06:25 -0700 Subject: [PATCH] Use exponential timeout increase on SYN sends --- src/conn.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conn.rs b/src/conn.rs index 714f6ef..34e9bc5 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -638,14 +638,16 @@ impl Connection { self.state = State::Closed { err: Some(err) }; } else { let seq = *syn; - *attempts += 1; + let new_attempt_count = *attempts + 1; + *attempts = new_attempt_count; let packet = self.syn_packet(seq); let _ = self.socket_events.send(SocketEvent::Outgoing(( packet.clone(), self.cid.peer.clone(), ))); + let timeout = self.config.initial_timeout * 2u32.pow(new_attempt_count.try_into().unwrap()); self.unacked - .insert_at(seq, packet, self.config.initial_timeout); + .insert_at(seq, packet, timeout); } } Endpoint::Acceptor(..) => {}