windy1 / zeroconf-rs

zeroconf is a cross-platform library that wraps underlying ZeroConf/mDNS implementations such as Bonjour or Avahi, providing an easy and idiomatic way to both register and browse services.
MIT License
77 stars 25 forks source link

BonjourEventLoop.poll(..) does not respect timeout on linux #26

Closed ERobsham closed 1 year ago

ERobsham commented 1 year ago

While troubleshooting an issue with a process at work where this library was used, I found that the BonjourEventLoop.poll(..) 'timeout' parameter is not being respected on linux, which lead to the original dev to make a loop kinda like the following to avoid a tight loop chewing up 100% CPU:

loop {
    event_loop.poll(Duration::from_secs(0))?;
    std::thread::sleep(Duration::from_secs(1));
}

(This led to other issues when dbus starts getting chatty if you have a situation where the network changes a lot)

After reviewing this library and the avahi docs, it seems pretty straightforward change to get this working, so I took a swing at it: https://github.com/windy1/zeroconf-rs/pull/25