mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 05:55:42 +00:00
Avoid panic on dropping a sc_network::service::out_events::Receiver. (#6458)
* Avoid panic on dropping a `Receiver`. * CI
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
use crate::Event;
|
use crate::Event;
|
||||||
use super::maybe_utf8_bytes_to_string;
|
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 parking_lot::Mutex;
|
||||||
use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64};
|
use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64};
|
||||||
use std::{
|
use std::{
|
||||||
@@ -119,8 +119,10 @@ impl fmt::Debug for Receiver {
|
|||||||
|
|
||||||
impl Drop for Receiver {
|
impl Drop for Receiver {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Empty the list to properly decrease the metrics.
|
if !self.inner.is_terminated() {
|
||||||
while let Some(Some(_)) = self.next().now_or_never() {}
|
// Empty the list to properly decrease the metrics.
|
||||||
|
while let Some(Some(_)) = self.next().now_or_never() {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user