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

manual_session: bugfix

Push the tasks onto the vector of stoppable tasks before starting them
to avoid a possible race condition.
draoi 2 лет назад
Родитель
Сommit
d60bb8bf33
1 измененных файлов с 2 добавлено и 3 удалено
  1. 2 3
      src/net/session/manual_session.rs

+ 2 - 3
src/net/session/manual_session.rs

@@ -82,16 +82,15 @@ impl ManualSession {
     pub async fn connect(self: Arc<Self>, addr: Url) {
         let ex = self.p2p().executor();
         let task = StoppableTask::new();
+        self.connect_slots.lock().await.push(task.clone());
 
-        task.clone().start(
+        task.start(
             self.clone().channel_connect_loop(addr),
             // Ignore stop handler
             |_| async {},
             Error::NetworkServiceStopped,
             ex,
         );
-
-        self.connect_slots.lock().await.push(task);
     }
 
     /// Creates a connector object and tries to connect using it