New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cupsEnumDests to finish when receiving the ALL_FOR_NOW avahi event #4989
Conversation
cupsEnumDests listens for avahi answers for `msec` milliseconds (where `msec` is given as a parameter to cupsEnumDests). avahi sends an ALL_FOR_NOW event [1] when "more records will probably not show up in the near future". This means that from the reception of ALL_FOR_NOW to the timeout triggering, cupsEnumDests basically does nothing but block the caller. Also, since the caller can't know how long it will take cupsEnumDests to receive all information from avahi, this means developers are encouraged to use "big enough" values for `msec`, thus blocking their calling threads unnecessarily. This patch makes cupsEnumDests react to the ALL_FOR_NOW event and finish as soon as all avahi caches have been read and all static servers have been queried. No behavior is changed when HAVE_DNSSD is defined. [1] http://www.avahi.org/doxygen/html/defs_8h.html#af7ff3b95259b3441a282b87d82eebd87a430e1134047305e7b892e784cf72f815
mDNSResponder has a similar mechanism, however in practice it has not proven reliable since all it means is that there are no more responses queued up... Will think about how we can make this better... |
OK, I have a better (generic) fix for this that uses some of the tricks from the dnssd backend to return early when we know we have all responses. Doing some more testing and will push a change once I'm satisfied. |
Cool, thanks for working on this. Do you have your solution published anywhere so I can test it too? |
Sorry, no, I'm just working directly on master for this change. But it shouldn't be too much longer before I push it to Github... |
…ave been discovered (Issue #4989) Also update the code to generate the same queue names as cupsd does for IPP Everywhere printers.
Please verify the fix in Github resolves the problems you were having. |
I added a couple of comments to your commit. Do you want me to modify my PR to fix those? Or do you prefer to work on them yourself? |
@antlarr I'm doing follow-up testing on a few Linux distros now (first pass mainly tested macOS) and had found the issues you have reported in the comments to the commit. I have some more changes for Avahi coming... |
Also fix timeouts to track elapsed time so the timeout is more accurate.
OK, just pushed more changes that seem to make Ubuntu happy. |
Yes, I'll probably keep testing on our other supported platforms (Windows in particular) but you should be good to go on Linux. |
cupsEnumDests listens for avahi answers for
msec
milliseconds (wheremsec
is given as a parameter to cupsEnumDests). avahi sends anALL_FOR_NOW event [1] when "more records will probably not show up in
the near future". This means that from the reception of ALL_FOR_NOW
to the timeout triggering, cupsEnumDests basically does nothing but
block the caller. Also, since the caller can't know how long it will
take cupsEnumDests to receive all information from avahi, this means
developers are encouraged to use "big enough" values for
msec
,thus blocking their calling threads unnecessarily.
This patch makes cupsEnumDests react to the ALL_FOR_NOW event and
finish as soon as all avahi caches have been read and all static
servers have been queried.
No behavior is changed when HAVE_DNSSD is defined.
[1] http://www.avahi.org/doxygen/html/defs_8h.html#af7ff3b95259b3441a282b87d82eebd87a430e1134047305e7b892e784cf72f815