Skip to content

Commit

Permalink
Use exponential timeout increase on SYN sends
Browse files Browse the repository at this point in the history
  • Loading branch information
carver committed Jun 7, 2023
1 parent e044f91 commit 96802e9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,16 @@ impl<const N: usize, P: ConnectionPeer> Connection<N, P> {
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(..) => {}
Expand Down

0 comments on commit 96802e9

Please sign in to comment.