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

channel: safely shutdown the channel when an error is triggered

draoi 2 лет назад
Родитель
Сommit
7959d9741c
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      src/net/channel.rs

+ 4 - 0
src/net/channel.rs

@@ -281,6 +281,8 @@ impl Channel {
                         target: "net::channel::main_receive_loop()",
                         "Stopping channel {:?}", self
                     );
+                    self.stop().await;
+
                     return Err(Error::ChannelStopped)
                 }
             };
@@ -301,6 +303,8 @@ impl Channel {
                     // We will reject further connections from this peer
                     self.p2p().hosts().mark_rejected(self.address()).await;
 
+                    self.stop().await;
+
                     return Err(Error::ChannelStopped)
                 }
                 Err(_) => unreachable!("You added a new error in notify()"),