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)
This commit is contained in:
committed by
GitHub
parent
3773800133
commit
c8168adeb2
@@ -121,7 +121,7 @@ impl<'a> ConnectionManager<'static> {
|
||||
async fn handle_new_message(&mut self, msg: Vec<u8>) -> io::Result<()> {
|
||||
if let ConnectionState::Reconnecting(conn_reconnector) = &mut self.state {
|
||||
// do a single poll rather than await for future to completely resolve
|
||||
let new_connection = match futures::poll!(conn_reconnector) {
|
||||
let new_connection = match futures::poll(conn_reconnector).await {
|
||||
Poll::Pending => {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::BrokenPipe,
|
||||
|
||||
@@ -71,7 +71,6 @@ impl<'a> Future for ConnectionReconnector<'a> {
|
||||
"we failed to re-establish connection to {} - {:?} (attempt {})",
|
||||
self.address, e, self.current_retry_attempt
|
||||
);
|
||||
self.current_retry_attempt += 1;
|
||||
|
||||
// we failed to re-establish connection - continue exponential backoff
|
||||
|
||||
@@ -95,6 +94,7 @@ impl<'a> Future for ConnectionReconnector<'a> {
|
||||
self.current_backoff_delay.reset(next);
|
||||
|
||||
self.connection = tokio::net::TcpStream::connect(self.address).boxed();
|
||||
self.current_retry_attempt += 1;
|
||||
|
||||
Poll::Pending
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ impl Client {
|
||||
runtime_handle: Handle::try_current()
|
||||
.expect("The client MUST BE used within tokio runtime context"),
|
||||
connections_managers: HashMap::new(),
|
||||
initial_reconnection_backoff: config.maximum_reconnection_backoff,
|
||||
maximum_reconnection_backoff: config.initial_reconnection_backoff,
|
||||
initial_reconnection_backoff: config.initial_reconnection_backoff,
|
||||
maximum_reconnection_backoff: config.maximum_reconnection_backoff,
|
||||
initial_connection_timeout: config.initial_connection_timeout,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user