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

cupsEnumDests: Provide notification of print queue additions and removals #5024

Open
NilanjanaLodh opened this Issue Jun 8, 2017 · 7 comments

Comments

Projects
None yet
4 participants
@NilanjanaLodh
Copy link

NilanjanaLodh commented Jun 8, 2017

CUPS version: latest snapshot of this repo
I used cupsEnumDests() in my program(with no time out); and inside my callback function I try to detect if the notification is for a removed printer in the way it's mentioned in the cups pm
i.e

if (flags & CUPS_DEST_FLAGS_REMOVED)
{
   /*
    * Remove destination ...
    */
}

I tested by removing some printers after the enumeration started, however, the callback function was not called with the CUPS_DEST_FLAGS_REMOVED flag set. I tried by removing both, network discovered printers as well as local printers(without success)

@michaelrsweet michaelrsweet self-assigned this Jun 8, 2017

@michaelrsweet michaelrsweet added this to the Future milestone Jun 8, 2017

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator

michaelrsweet commented Jun 8, 2017

Right now we don't track queue removals for cupsEnumDests since a) that is a fairly rare event and b) the cost to poll or to setup a subscription to watch for queues getting add/removed is prohibitive.

I'll keep this bug around to add support for this in a future release when using a large (or indefinite) timeout, however for typical usage (building a list of printers for a print dialog) this should not be a serious issue.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator

michaelrsweet commented Jun 8, 2017

Bonjour removals should be returned, although Avahi might have bugs here...

@michaelrsweet michaelrsweet changed the title cupsEnumDests() does not notify removal of printers during enumeration. cupsEnumDests: Provide notification of print queue removals Jun 8, 2017

@michaelrsweet michaelrsweet changed the title cupsEnumDests: Provide notification of print queue removals cupsEnumDests: Provide notification of print queue additions and removals Jun 8, 2017

@NilanjanaLodh

This comment has been minimized.

Copy link

NilanjanaLodh commented Jun 8, 2017

Yes, I actually had trouble with printers discovered via Avahi I guess.
I set up a few printers on my virtual machine(in bridged adapter mode) thus simulating a network printer.

When I stop the cups service on the virtual machine, the printer removal isn't notified in my program.
So I think, a workaround to detect removal of printers would be to continuously poll using cupsEnumDests() repeatedly(with a small timeout) , and compare the new list with the old list of printers to see if any one is removed

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator

michaelrsweet commented Jun 8, 2017

Don't poll unless you need the information. So when the print dialog is open and the printer chooser/list is displayed, but not otherwise.

@jsmeix

This comment has been minimized.

Copy link

jsmeix commented Jun 9, 2017

@NilanjanaLodh
a side note in general regarding your
"continuously poll ... with a small timeout"
and the response from @michaelrsweet
"Don't poll unless you need the information":

A longer time ago we (at SUSE) noticed a major load issue
on our internal print server because some stupid desktop stuff
continuously polled our print server to display automatically
and continuously up-to-date print queue information to the user.
This behaviour caused higher and continuous load
on our print server than the actual printing operations
(including processing and filtering of the print job data).

I guess the developer(s) of that functionality had developed
and tested it only in their small testing networks with only
a few simultaneously running client systems (perhaps
even only on a local system with the local cupsd).

Continuously polling does not scale for big (up to huge)
company or corporate networks with many client systems
(up to thousands of simultaneously running client systems).

Instead of automatically and continuously polling
only bother the CUPS server (like any other sever process)
when the user actively requests information e.g. when the
user clicks a button or launches a printing related dialog.
This means that a pure print queue information notification
should actually be a dialog with a [Refresh] button so that
the user can and must actively request updated information.

@uvguy

This comment has been minimized.

Copy link

uvguy commented Jun 14, 2017

I believe using epoll/kqueue backend instead of poll could raise higher throughput here if this is used correctly.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator

michaelrsweet commented Jun 15, 2017

@uvguy in this case polling refers to sending a query request to the CUPS scheduler (cupsd) repeatedly to get an updated list of print queues, not to the poll() system call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment