Просмотр исходного кода

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 год назад
Родитель
Сommit
eb5b8e3684
1 измененных файлов с 3 добавлено и 3 удалено
  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!(
                 target: "net::outbound_session::try_connect()",
                 "[P2P] Outbound slot #{} connected [{}]",
@@ -340,9 +343,6 @@ impl Slot {
                 channel_id: channel.info.id
             });
 
-            // At this point we've managed to connect.
-
-            let stop_sub = channel.subscribe_stop().await?;
             // Setup new channel
             if let Err(err) =
                 self.session().register_channel(channel.clone(), self.p2p().executor()).await