Skip to content

Commit c8168ad

Browse files
authored
Bugfix/issue#231 (#233)
* Increasing reconnection attempt after actually computing delay * Constructor mix-up.... * Replaced poll! macro with poll call (after macro expansion that's syntactically identical)
1 parent 3773800 commit c8168ad

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

common/client-libs/multi-tcp-client/src/connection_manager/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a> ConnectionManager<'static> {
121121
async fn handle_new_message(&mut self, msg: Vec<u8>) -> io::Result<()> {
122122
if let ConnectionState::Reconnecting(conn_reconnector) = &mut self.state {
123123
// do a single poll rather than await for future to completely resolve
124-
let new_connection = match futures::poll!(conn_reconnector) {
124+
let new_connection = match futures::poll(conn_reconnector).await {
125125
Poll::Pending => {
126126
return Err(io::Error::new(
127127
io::ErrorKind::BrokenPipe,

common/client-libs/multi-tcp-client/src/connection_manager/reconnector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ impl<'a> Future for ConnectionReconnector<'a> {
7171
"we failed to re-establish connection to {} - {:?} (attempt {})",
7272
self.address, e, self.current_retry_attempt
7373
);
74-
self.current_retry_attempt += 1;
7574

7675
// we failed to re-establish connection - continue exponential backoff
7776

@@ -95,6 +94,7 @@ impl<'a> Future for ConnectionReconnector<'a> {
9594
self.current_backoff_delay.reset(next);
9695

9796
self.connection = tokio::net::TcpStream::connect(self.address).boxed();
97+
self.current_retry_attempt += 1;
9898

9999
Poll::Pending
100100
}

common/client-libs/multi-tcp-client/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl Client {
6060
runtime_handle: Handle::try_current()
6161
.expect("The client MUST BE used within tokio runtime context"),
6262
connections_managers: HashMap::new(),
63-
initial_reconnection_backoff: config.maximum_reconnection_backoff,
64-
maximum_reconnection_backoff: config.initial_reconnection_backoff,
63+
initial_reconnection_backoff: config.initial_reconnection_backoff,
64+
maximum_reconnection_backoff: config.maximum_reconnection_backoff,
6565
initial_connection_timeout: config.initial_connection_timeout,
6666
}
6767
}

0 commit comments

Comments
 (0)