Skip to content

Commit

Permalink
fix(comms): dial if connection is not connected (#5223)
Browse files Browse the repository at this point in the history
Description
---
Fix bug where recently disconnected connections do not get redialled

Motivation and Context
---
The connectivity manager pool maintains a list of connections including recently disconnected. These are cleared out periodically. The connectivity manager should not return disconnected connections to the caller.

How Has This Been Tested?
---
Manually: Connection is dialled when pool says the connection is not connected.

<!-- Does this include a breaking change? If so, include this line as a footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
  • Loading branch information
sdbondi committed Mar 8, 2023
1 parent 6edbb1c commit 0a060b6
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions comms/core/src/connectivity/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,31 @@ impl ConnectivityManagerActor {
},
}
match self.pool.get(&node_id) {
Some(state) => {
if !state.is_connected() {
warn!(
target: LOG_TARGET,
"Existing connection is present but is_connected is false for some reason...."
);
}

// The connection pool may temporarily contain a connection that is not connected so we need to check this.
Some(state) if state.is_connected() => {
if let Some(reply_tx) = reply_tx {
let _result = reply_tx.send(Ok(state.connection().cloned().expect("Already checked")));
}
},
None => {
info!(
target: LOG_TARGET,
"No existing connection found for peer `{}`. Dialing...",
node_id.short_str()
);
maybe_state => {
match maybe_state {
Some(state) => {
info!(
target: LOG_TARGET,
"Connection was previously attempted for peer {}. Current status is '{}'. Dialing again...",
node_id.short_str(),
state.status()
);
},
None => {
info!(
target: LOG_TARGET,
"No connection for peer {}. Dialing...",
node_id.short_str(),
);
},
}

if let Err(err) = self.connection_manager.send_dial_peer(node_id, reply_tx).await {
error!(
target: LOG_TARGET,
Expand Down

0 comments on commit 0a060b6

Please sign in to comment.