[Printing-architecture] Concept for PPD-less CUPS-spooled printing on Bonjour-discovered network printers

Michael Sweet msweet at apple.com
Wed Nov 13 14:52:27 UTC 2013


Tim,

WRT GTK+ and blocking APIs in general, it is really really hard to get away from blocking behavior when you are dealing with networking.  The strategy we opted for was to support timeouts and asynchronous cancellation of blocking/semi-blocking calls so that applications and toolkits can wrap those calls appropriately.

Ideally everyone would adopt Grand Dispatch (patches were provided to the GCC folks a long time ago) which essentially adds singletons (blocks) to C/C++/ObjC along with lighter-weight threads and basic scheduling queues (async for running blocks on parallels threads and sync for serializing a series of blocks on a particular thread).  This greatly simplifies thread management and offers a compelling replacement for callback functions, thus the support in libcups for them…

But in the meantime, GTK+ and others should be doing printer discovery and queries on a separate thread from the main thread, otherwise they WILL block even if every API CUPS provided was “non-blocking” - networks are unpredictable.

For the record, we *did* consider making cupsGetDests run a background thread doing the equivalent of cupsEnumDests so that callers would get a current snapshot of the available printers.  However, doing it without having the application “opt in” would cause a lot of problems for programs like Firefox that think it is OK to unload a dynamic library like libcups that is not designed for such use (few are), and providing an opt-in method (cupsStartEnumDests or something like that) isn’t much better - code changes are still required, so why not just use the new API in the first place?


On Nov 13, 2013, at 5:38 AM, Tim Waugh <twaugh at redhat.com> wrote:

> On Tue, 2013-11-12 at 23:23 +0100, Till Kamppeter wrote:
>> Another question is whether cupsEnumDests() can run in parallel with
>> other, independent services, in my case Tim Waugh's backward
>> compatibility CUPS browsing/broadcasting.
> 
> It isn't meant to. The BrowsePoll and Browsing(send) support is for
> legacy sites, and Browsing(recv) is a stop-gap until all the dialogs use
> cupsEnumDests() or the equivalent. For GTK+, it uses its own
> implementation (as cupsEnumDests is blocking -- Mike, please stop
> writing blocking interfaces ;-) ). For Qt, I've written a patch to use
> cupsEnumDests():
> https://bugzilla.redhat.com/show_bug.cgi?id=980952
> 
> Tim.
> */
> 

_______________________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair



More information about the Printing-architecture mailing list