mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 05:38:00 +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 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() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user