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

inbound_session: don't stop tasks that haven't been started

fixes a bug in which we would try to stop PingSelfProcess in non-inbound
nodes, resulting in StoppableTask.stop() hanging forever.
draoi 2 лет назад
Родитель
Сommit
b1d16e1153
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      src/net/session/inbound_session.rs

+ 7 - 0
src/net/session/inbound_session.rs

@@ -112,6 +112,7 @@ impl InboundSession {
                 .await?;
                 .await?;
         }
         }
 
 
+        debug!(target: "net::inbound_session", "Starting ping_self process");
         self.ping_self.clone().start().await;
         self.ping_self.clone().start().await;
 
 
         Ok(())
         Ok(())
@@ -119,6 +120,11 @@ impl InboundSession {
 
 
     /// Stops the inbound session.
     /// Stops the inbound session.
     pub async fn stop(&self) {
     pub async fn stop(&self) {
+        if self.p2p().settings().inbound_addrs.is_empty() {
+            info!(target: "net::inbound_session", "[P2P] Not configured for inbound connections.");
+            return
+        }
+
         let acceptors = &*self.acceptors.lock().await;
         let acceptors = &*self.acceptors.lock().await;
         for acceptor in acceptors {
         for acceptor in acceptors {
             acceptor.stop().await;
             acceptor.stop().await;
@@ -129,6 +135,7 @@ impl InboundSession {
             accept_task.stop().await;
             accept_task.stop().await;
         }
         }
 
 
+        debug!(target: "net::inbound_session", "Stopping ping_self process");
         self.ping_self.clone().stop().await;
         self.ping_self.clone().stop().await;
     }
     }