Skip to content
Snippets Groups Projects
Commit 6aa8965f authored by Roman Borschel's avatar Roman Borschel Committed by GitHub
Browse files

Avoid panic on dropping a `sc_network::service::out_events::Receiver`. (#6458)

* Avoid panic on dropping a `Receiver`.

* CI
parent d9776d82
No related merge requests found
......@@ -35,7 +35,7 @@
use crate::Event;
use super::maybe_utf8_bytes_to_string;
use futures::{prelude::*, channel::mpsc, ready};
use futures::{prelude::*, channel::mpsc, ready, stream::FusedStream};
use parking_lot::Mutex;
use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64};
use std::{
......@@ -119,8 +119,10 @@ impl fmt::Debug for Receiver {
impl Drop for Receiver {
fn drop(&mut self) {
// Empty the list to properly decrease the metrics.
while let Some(Some(_)) = self.next().now_or_never() {}
if !self.inner.is_terminated() {
// Empty the list to properly decrease the metrics.
while let Some(Some(_)) = self.next().now_or_never() {}
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment