Skip to content

Commit

Permalink
wait_readable flag; waiting for the socket is now turned off by defau…
Browse files Browse the repository at this point in the history
…lt due to suspicions that it does not work quite right with embassy-net
  • Loading branch information
ivmarkov committed Dec 11, 2024
1 parent 426847c commit e8d94e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion edge-mdns/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ where
send_buf: SB,
rand: fn(&mut [u8]),
broadcast_signal: &'a Signal<M, ()>,
wait_readable: bool,
}

impl<'a, M, R, S, RB, SB> Mdns<'a, M, R, S, RB, SB>
Expand Down Expand Up @@ -174,9 +175,17 @@ where
send_buf,
rand,
broadcast_signal,
wait_readable: false,
}
}

/// Sets whether the mDNS service should wait for the socket to be readable before reading.
///
/// Setting this to `true` is only useful when the read buffer is shared with other tasks
pub fn wait_readable(&mut self, wait_readable: bool) {
self.wait_readable = wait_readable;
}

/// Runs the mDNS service, handling queries and responding to them, as well as broadcasting
/// mDNS answers and handling responses to our own queries.
///
Expand Down Expand Up @@ -280,7 +289,9 @@ where
let mut recv = self.recv.lock().await;

loop {
recv.readable().await.map_err(MdnsIoError::IoError)?;
if self.wait_readable {
recv.readable().await.map_err(MdnsIoError::IoError)?;
}

{
let mut recv_buf = self
Expand Down

0 comments on commit e8d94e0

Please sign in to comment.