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

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

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions client/network/src/service/out_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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() {}
}
}
}

Expand Down