|
@@ -78,7 +78,10 @@ pub struct OutboundSession {
|
|
|
p2p: Weak<P2p>,
|
|
p2p: Weak<P2p>,
|
|
|
connect_slots: Mutex<Vec<StoppableTaskPtr>>,
|
|
connect_slots: Mutex<Vec<StoppableTaskPtr>>,
|
|
|
slot_info: Mutex<Vec<OutboundInfo>>,
|
|
slot_info: Mutex<Vec<OutboundInfo>>,
|
|
|
|
|
+ /// Subscriber used to signal channels processing
|
|
|
channel_subscriber: SubscriberPtr<Result<ChannelPtr>>,
|
|
channel_subscriber: SubscriberPtr<Result<ChannelPtr>>,
|
|
|
|
|
+ /// Flag to toggle channel_subscriber notifications
|
|
|
|
|
+ notify: Mutex<bool>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl OutboundSession {
|
|
impl OutboundSession {
|
|
@@ -89,6 +92,7 @@ impl OutboundSession {
|
|
|
connect_slots: Mutex::new(Vec::new()),
|
|
connect_slots: Mutex::new(Vec::new()),
|
|
|
slot_info: Mutex::new(Vec::new()),
|
|
slot_info: Mutex::new(Vec::new()),
|
|
|
channel_subscriber: Subscriber::new(),
|
|
channel_subscriber: Subscriber::new(),
|
|
|
|
|
+ notify: Mutex::new(false),
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -175,7 +179,9 @@ impl OutboundSession {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Notify that channel processing has been finished
|
|
// Notify that channel processing has been finished
|
|
|
- self.channel_subscriber.notify(Ok(channel)).await;
|
|
|
|
|
|
|
+ if *self.notify.lock().await {
|
|
|
|
|
+ self.channel_subscriber.notify(Ok(channel)).await;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Wait for channel to close
|
|
// Wait for channel to close
|
|
|
stop_sub.unwrap().receive().await;
|
|
stop_sub.unwrap().receive().await;
|
|
@@ -190,7 +196,9 @@ impl OutboundSession {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Notify that channel processing has been finished
|
|
// Notify that channel processing has been finished
|
|
|
- self.channel_subscriber.notify(Err(err)).await;
|
|
|
|
|
|
|
+ if *self.notify.lock().await {
|
|
|
|
|
+ self.channel_subscriber.notify(Err(err)).await;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -242,6 +250,16 @@ impl OutboundSession {
|
|
|
pub async fn subscribe_channel(&self) -> Subscription<Result<ChannelPtr>> {
|
|
pub async fn subscribe_channel(&self) -> Subscription<Result<ChannelPtr>> {
|
|
|
self.channel_subscriber.clone().subscribe().await
|
|
self.channel_subscriber.clone().subscribe().await
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /// Enable channel_subscriber notifications.
|
|
|
|
|
+ pub async fn enable_notify(self: Arc<Self>) {
|
|
|
|
|
+ *self.notify.lock().await = true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /// Disable channel_subscriber notifications.
|
|
|
|
|
+ pub async fn disable_notify(self: Arc<Self>) {
|
|
|
|
|
+ *self.notify.lock().await = false;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[async_trait]
|
|
#[async_trait]
|