Skip to content

Commit

Permalink
fix(protocols/mdns): fix typo and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gallegogt committed Jul 20, 2022
1 parent 10581c7 commit ebd0c79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion protocols/mdns/CHANGELOG.md
Expand Up @@ -4,7 +4,7 @@

- Allow users to choose between async-io and tokio runtime
in the mdns protocol implementation. `async-io` is a default
feature, with an additional `tokyo` feature (see [PR 2748])
feature, with an additional `tokio` feature (see [PR 2748])

- Update to `libp2p-core` `v0.35.0`.

Expand Down
15 changes: 5 additions & 10 deletions protocols/mdns/src/behaviour/iface.rs
Expand Up @@ -201,24 +201,20 @@ where
params: &impl PollParameters,
) -> Option<(PeerId, Multiaddr, Instant)> {
// Poll receive socket.
loop {
match self.recv_socket.poll_read(cx, &mut self.recv_buffer) {
Poll::Ready(Ok((len, from))) => {
while let Poll::Ready(data) = self.recv_socket.poll_read(cx, &mut self.recv_buffer) {
match data {
Ok((len, from)) => {
if let Some(packet) = MdnsPacket::new_from_bytes(&self.recv_buffer[..len], from)
{
self.inject_mdns_packet(packet, params);
}
}
Poll::Ready(Err(err)) if err.kind() == std::io::ErrorKind::WouldBlock => {
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => {
// No more bytes available on the socket to read
break;
}
Poll::Ready(Err(err)) => {
Err(err) => {
log::error!("failed reading datagram: {}", err);
break;
}
Poll::Pending => {
break;
}
}
}
Expand All @@ -233,7 +229,6 @@ where
Poll::Ready(Ok(_)) => log::trace!("sent packet on iface {}", self.addr),
Poll::Ready(Err(err)) => {
log::error!("error sending packet on iface {} {}", self.addr, err);
break;
}
Poll::Pending => {
self.send_buffer.push_front(packet);
Expand Down

0 comments on commit ebd0c79

Please sign in to comment.