Sfoglia il codice sorgente

Revert "inbound_session: remove redudant subscribe_stop() call"

This reverts commit 5d302f34359b7f5c0a906fbf4dfe3b3538fbaf3d.
darkfi 1 anno fa
parent
commit
3136988c48
1 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. 14 2
      src/net/session/inbound_session.rs

+ 14 - 2
src/net/session/inbound_session.rs

@@ -26,7 +26,7 @@
 use std::sync::{Arc, Weak};
 
 use async_trait::async_trait;
-use log::{error, info, warn};
+use log::{debug, error, info, warn};
 use smol::{lock::Mutex, Executor};
 use url::Url;
 
@@ -184,8 +184,20 @@ impl InboundSession {
             channel_id: channel.info.id,
         });
 
+        let stop_sub = channel.subscribe_stop().await;
+
         match self.register_channel(channel.clone(), ex.clone()).await {
-            Ok(()) => {}
+            Ok(()) => {
+                if let Ok(stop_sub) = stop_sub {
+                    // Wait for a stop signal, then cleanup.
+                    stop_sub.receive().await;
+
+                    debug!(
+                        target: "net::inbound_session::setup_channel()",
+                        "Received stop_sub, channel removed from P2P",
+                    );
+                }
+            }
             Err(e) => {
                 warn!(
                     target: "net::inbound_session::setup_channel()",