From c8f496a7424e151ff485e7aafde0cf94676a0998 Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 7 Mar 2023 15:35:48 +0400 Subject: [PATCH 1/3] fix(comms): dial if connection is not connected --- comms/core/src/connectivity/manager.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/comms/core/src/connectivity/manager.rs b/comms/core/src/connectivity/manager.rs index f3e78cf30c..2ba8bd5098 100644 --- a/comms/core/src/connectivity/manager.rs +++ b/comms/core/src/connectivity/manager.rs @@ -315,22 +315,18 @@ 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...." - ); - } - + 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 => { + maybe_state => { info!( target: LOG_TARGET, - "No existing connection found for peer `{}`. Dialing...", + "No connection found for peer (status={}) `{}`. Dialing...", + maybe_state + .map(|s| s.status().to_string()) + .unwrap_or_else(|| "NotConnected".to_string()), node_id.short_str() ); if let Err(err) = self.connection_manager.send_dial_peer(node_id, reply_tx).await { From 608da1f4195ebfd7c99add8ec9f3ef236cac47df Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 7 Mar 2023 15:50:37 +0400 Subject: [PATCH 2/3] review comments: add comment explaining pool --- comms/core/src/connectivity/manager.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comms/core/src/connectivity/manager.rs b/comms/core/src/connectivity/manager.rs index 2ba8bd5098..0f809a7a36 100644 --- a/comms/core/src/connectivity/manager.rs +++ b/comms/core/src/connectivity/manager.rs @@ -315,6 +315,7 @@ impl ConnectivityManagerActor { }, } match self.pool.get(&node_id) { + // 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"))); @@ -323,7 +324,7 @@ impl ConnectivityManagerActor { maybe_state => { info!( target: LOG_TARGET, - "No connection found for peer (status={}) `{}`. Dialing...", + "Connection is not connected (status={}) `{}`. Dialing...", maybe_state .map(|s| s.status().to_string()) .unwrap_or_else(|| "NotConnected".to_string()), From 80911a7262b39289ab8090888888ef404ec137bf Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 7 Mar 2023 15:59:17 +0400 Subject: [PATCH 3/3] further improve dial logging --- comms/core/src/connectivity/manager.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/comms/core/src/connectivity/manager.rs b/comms/core/src/connectivity/manager.rs index 0f809a7a36..6addf68387 100644 --- a/comms/core/src/connectivity/manager.rs +++ b/comms/core/src/connectivity/manager.rs @@ -322,14 +322,24 @@ impl ConnectivityManagerActor { } }, maybe_state => { - info!( - target: LOG_TARGET, - "Connection is not connected (status={}) `{}`. Dialing...", - maybe_state - .map(|s| s.status().to_string()) - .unwrap_or_else(|| "NotConnected".to_string()), - node_id.short_str() - ); + 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,