-
Notifications
You must be signed in to change notification settings - Fork 169
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
Timeout for cupsEnumDests() too short (using Linux with Avahi) #751
Comments
"cups.lpstat -l -e" lists ALL available print destinations and tells in the first word of each output line, which queue name you have to use with commands like "lp". It does not only list permanent CUPS queues, which you create with a printer setup tool or with the "lpadmin" command, but also IPP print destinations to which CUPS prints without needing a permanent print queue, where CUPS creates a temporary queues just for printing your job. Current CUPS unfortunately has a bug, making "cups.lpstat -l -e" listing only the permanent queues, the same as it lists with "cups.lpstat -v", ending up not having a command line tool showing the IPP print destinations with the CUPS queue names to use for printing to them ("driverless" only shows the URIs, not the CUPS queue names). The problem is that the "cupsGetDests()" function has a too short timeout when waiting for Avahi resolving the DNS-SD records of the discovered IPP print destinations. The loop stops before any of the answers arrives, resulting in only the permanent queues being listed, which are taken directkly from CUPS and do not requires DNS-SD browsing and resolving. This commit raises the timeout from 250 msec to 1000 msec and this makes the discovered IPP destinations appear. "cups.lpstat -l -e" needs a full second now, but gives the expected results. See OpenPrinting/cups#751
Hmm... never had this problem on Fedora, is your network full mDNS devices, so Avahi is not able to respond in time? My current Fedora Linux 38 (CUPS 2.4.6, Avahi 0.8, nss-mdns 0.15.1, cups-browsed does not run and my local printers are not advertised) shows the following: (Canon IPP-USB printer connected by USB and network, and pure network HP printer) Complete driverless output: If the network is not crowded with mDNS or mDNS is not delayed by a third party (I recall Avahi has reflector feature, which can relay mDNS between different networks, but it is slower), there can be a downstream patch/bug in Avahi, which causes delays. Marking @pemensik for heads-up, he might know whether there is such issue in Avahi. |
@tillkamppeter any update? |
Sorry for the late reply, but for me there are indeed many DNS-SD entries. Once I am running several Printer Applications with each having several internal print queues, and second, I have many network interfaces, due to running virtual machinbes and containers, where the appropriate managing software creates (virtual) network interfaces to connect these instances with the host. The Printer Applications appear on each interface again, multiplying the number of entries even more. Also non-printer entries, like network appliances and servers, web admin interfaces, ... get multiplied.
|
IMO this is not a common setup which users will have (even on cups-sharing admins will probably hardwire the queues permanently than relying on Avahi) and part of the problem lies in Avahi as well, but I would propose a new public function in libcups which would accept the msec parameter which will be used for cups_enum_dests() timeout, and a new 'timeout' option for lpstat. So anyone who needs more time can set the function to do so, and the common use cases won't be hindered by higher timeout. |
@zdohnal The public api ( |
Yes, just extending the default timeout to 10 sec is no problems. Avahi tells when it has finished and so we will not be stuck by 10 seconds, and have Avahi taking ~1 sec on a busy system is no problem, much better than entries missing. |
@tillkamppeter @michaelrsweet ack - let's go with changed default - I was worried how cupsGetDests() will perform on a system with disabled mDNS service, but libcups is not able to create a new client if there is no running mDNS service, so there is no delay. |
The current timeout is not able to list all network devices if there are many IPP services on mDNS (the tested number is 165 services). Raising the timeout to 1s does not slow libcups if there are less services (Avahi returns earlier) or if Avahi does not run on the system (libcups cannot create an Avahi client in that case), and provides time frame for getting reasonable amount of IPP services (big enterprise servers will use permanent queues and printer profiles than mDNS). Fixes OpenPrinting#751
The current timeout is not able to list all network devices if there are many IPP services on mDNS (the tested number is 165 services). Raising the timeout to 1s does not slow libcups if there are less services (Avahi returns earlier) or if Avahi does not run on the system (libcups cannot create an Avahi client in that case), and provides time frame for getting reasonable amount of IPP services (big enterprise servers will use permanent queues and printer profiles than mDNS). Fixes #751
The relevant master commit 082c5ae12a
Forgot to include in 2.4.8... fixes #751 for series 2.4.x.
Describe the bug
Already for some time
lpstat -e
only lists the permanent CUPS queues, not discovered IPP printers on which CUPS can print using a temporary queue. Investigating the code revealed that the timeout for asynchronous Avahi resolving in thecupsGetDests()
API function which uses the internal (static) functioncups_get_dests()
with its is too short.In
cups/dest.c
is defined:setting it to
solves the problem. Now the loop in
cups_get_dests()
stays running long enough for the asynchronous Avahi resolving calls for the discovered IPP print destinatiuons to finish and the results being caught.I have found out that for timeouts < 620 no resolving process at all is finishing in time and so no discovered IPP print destinations get listed and with only a little more than 620 msec, for example 630 msec, all the resolving processes finish and all the resukts get taken into account, making all printers listed (I had 27 in the test). Th 100 msec seem to be a very safe bet.
To Reproduce
Without the fix
ouputs one line for each permanent CUPS queue, so if
lpstat -v
outputs a line likethe
lpstat -l -e
gives the corresponding lineSo we get one line for each permanent CUPS queue and no further lines for discovered printers.
With the timeout corrected and with IPP print destinations available (The
driverless
command lists all of them) the commandhas more output, in addition to the lines for permanent queues there are lines for discovered IPP printers.
For each output line of
driverless
likeyou get a line
(at least if no permanent queue was created for this URI.
System Information:
libcups.so.2
)The text was updated successfully, but these errors were encountered: