Bladeren bron

net/outbound_session: subscribe to stop before printing info messages

Otherwise we delay the subscribe_stop() by a number of miliseconds which
could lead to race conditions.
darkfi 1 jaar geleden
bovenliggende
commit
eb5b8e3684
1 gewijzigde bestanden met toevoegingen van 3 en 3 verwijderingen
  1. 3 3
      src/net/session/outbound_session.rs

+ 3 - 3
src/net/session/outbound_session.rs

@@ -328,6 +328,9 @@ impl Slot {
                 }
                 }
             };
             };
 
 
+            // At this point we've managed to connect.
+            let stop_sub = channel.subscribe_stop().await?;
+
             info!(
             info!(
                 target: "net::outbound_session::try_connect()",
                 target: "net::outbound_session::try_connect()",
                 "[P2P] Outbound slot #{} connected [{}]",
                 "[P2P] Outbound slot #{} connected [{}]",
@@ -340,9 +343,6 @@ impl Slot {
                 channel_id: channel.info.id
                 channel_id: channel.info.id
             });
             });
 
 
-            // At this point we've managed to connect.
-
-            let stop_sub = channel.subscribe_stop().await?;
             // Setup new channel
             // Setup new channel
             if let Err(err) =
             if let Err(err) =
                 self.session().register_channel(channel.clone(), self.p2p().executor()).await
                 self.session().register_channel(channel.clone(), self.p2p().executor()).await