Skip to content

Commit 686306c

Browse files
Try to prevent RawPinger.recv returning an Err from killing the entire Pinger
1 parent 0c1a0c4 commit 686306c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/pinger.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{
1111
Arc,
1212
},
1313
task::{Context, Poll},
14+
thread,
1415
time::Duration,
1516
};
1617
#[cfg(feature = "stream")]
@@ -94,7 +95,15 @@ impl<V: IpVersion> Pinger<V> {
9495
u16,
9596
mpsc::UnboundedSender<(V, Instant, Instant)>,
9697
> = HashMap::new();
97-
'packets: while let Ok(maybe_packet) = raw_blocking.recv(&mut buf) {
98+
'packets: loop {
99+
let maybe_packet = match raw_blocking.recv(&mut buf) {
100+
Ok(maybe_packet) => maybe_packet,
101+
Err(_err) => {
102+
thread::yield_now();
103+
continue 'packets;
104+
}
105+
};
106+
98107
match &maybe_packet {
99108
Some(packet) if packet.identifier() == identifier => {
100109
let recv_instant = Instant::now();

0 commit comments

Comments
 (0)