diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index c6a9359c23b..b6cecda1b92 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -2,6 +2,8 @@ - Ensure `Multiaddr` handled and returned by `Behaviour` are `/p2p` terminated. See [PR 4596](https://github.com/libp2p/rust-libp2p/pull/4596). +- Fix a bug in the `Behaviour::poll` method causing missed mdns packets. + See [PR 4861](https://github.com/libp2p/rust-libp2p/pull/4861). ## 0.45.0 diff --git a/protocols/mdns/src/behaviour/iface.rs b/protocols/mdns/src/behaviour/iface.rs index 7fe97c38381..9302065cde2 100644 --- a/protocols/mdns/src/behaviour/iface.rs +++ b/protocols/mdns/src/behaviour/iface.rs @@ -312,14 +312,18 @@ where } Poll::Ready(Err(err)) if err.kind() == std::io::ErrorKind::WouldBlock => { // No more bytes available on the socket to read + continue; } Poll::Ready(Err(err)) => { tracing::error!("failed reading datagram: {}", err); + return Poll::Ready(()); } Poll::Ready(Ok(Err(err))) => { tracing::debug!("Parsing mdns packet failed: {:?}", err); + continue; } - Poll::Ready(Ok(Ok(None))) | Poll::Pending => {} + Poll::Ready(Ok(Ok(None))) => continue, + Poll::Pending => {} } return Poll::Pending;