Skip to content

libkcups: Rework CUPS Connection to optimize notify subscription

Mike Noe requested to merge work/noee/cupsconnection-mild-rework into master

CUPS notifies clients when certain events occur: Printer, server and job queue events. These notification events are defined and created by KCupsConnection using the CUPS subscription mechanism (dbus). Any consumer can then connect to the KCupsConnection and receive notification for any supported events.

KCupsConnection is a QThread and at creation, the events are connected to the dbus signals before the thread is started. All requests issued from clients are moved to the KCupsConnection for exec.

Currently, when the connection thread starts, if there are notify connects in-flight, the yield allows a subscription creation, interrupting the notify connections.  When the thread idles, additional notify connects from clients continue and this causes a subscription create/cancel/create dance until the last notify connect.

In addition, when the notify events are disconnected at consumer tear down, there are duplicate events that cause a subscription cancel/create/cancel dance that is unnecessary.

With this change the notify connects complete before thread start and we get a single subscription create. Duplicate events are not allowed in the connection list, the tear down cancel/create/cancel becomes just a single cancel on the initial subscription create.

Merge request reports