Explorar o código

channel: safely shutdown the channel when an error is triggered

draoi %!s(int64=2) %!d(string=hai) anos
pai
achega
7959d9741c
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  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()"),