Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 19826b9

Browse files
authored
Avoid panic on dropping a sc_network::service::out_events::Receiver. (#6458)
* Avoid panic on dropping a `Receiver`. * CI
1 parent 50eb257 commit 19826b9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

client/network/src/service/out_events.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
use crate::Event;
3636
use super::maybe_utf8_bytes_to_string;
3737

38-
use futures::{prelude::*, channel::mpsc, ready};
38+
use futures::{prelude::*, channel::mpsc, ready, stream::FusedStream};
3939
use parking_lot::Mutex;
4040
use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64};
4141
use std::{
@@ -119,8 +119,10 @@ impl fmt::Debug for Receiver {
119119

120120
impl Drop for Receiver {
121121
fn drop(&mut self) {
122-
// Empty the list to properly decrease the metrics.
123-
while let Some(Some(_)) = self.next().now_or_never() {}
122+
if !self.inner.is_terminated() {
123+
// Empty the list to properly decrease the metrics.
124+
while let Some(Some(_)) = self.next().now_or_never() {}
125+
}
124126
}
125127
}
126128

0 commit comments

Comments
 (0)