Bug 211465 - print/cups hangs on startup, when built without DBUS
Summary: print/cups hangs on startup, when built without DBUS
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-30 18:56 UTC by Mikhail T.
Modified: 2017-01-12 16:47 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (tijl)


Attachments
subscriptions.conf (522 bytes, text/plain)
2016-08-08 20:30 UTC, Mikhail Teterin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail T. 2016-07-30 18:56:24 UTC
When built without DBUS-option, cupsd-daemon will begin consuming 100% CPU upon startup. The log-messages say, repeatedly:

E [30/Jul/2016:14:49:54 -0400] File "/opt/libexec/cups/notifier/dbus" not available: No such file or directory
W [30/Jul/2016:14:49:54 -0400] Notifier for subscription 14 (dbus://) went away, retrying!
Comment 1 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-08 16:19:36 UTC
I cannot reproduce this.  cupsd built without DBUS starts just fine here and consumes no CPU.  I suspect you may have the cups_browsed service enabled.  That uses D-Bus to communicate with cupsd.
Comment 2 Mikhail Teterin freebsd_committer freebsd_triage 2016-08-08 16:22:14 UTC
(In reply to Tijl Coosemans from comment #1)
> cupsd built without DBUS starts just fine here and consumes no CPU

Was dbus installed on the build-machine at build-time?

> I suspect you may have the cups_browsed service enabled.

How would I check that? Thanks!
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-08 16:53:18 UTC
(In reply to Mikhail Teterin from comment #2)
> Was dbus installed on the build-machine at build-time?

Yes, but in the stage directory nothing (except etc/dbus-1/system.d/cups.conf but that's irrelevant) matches dbus so it was disabled correctly.

> How would I check that?

Do you have cups-filters installed?  Is there cups_browsed_enable=YES in /etc/rc.conf?  Check with 'ps xa | grep cups' or maybe 'service cups_browsed status'.
Comment 4 Mikhail Teterin freebsd_committer freebsd_triage 2016-08-08 17:01:30 UTC
(In reply to Tijl Coosemans from comment #3)
> > Was dbus installed on the build-machine at build-time?

> Yes, but in the stage directory nothing (except etc/dbus-1/system.d/cups.conf > but that's irrelevant) matches dbus so it was disabled correctly.

Sorry, I do not understand the above reply... In my case dbus was installed normally, when the build of cups was performed.

I suspect, some dbus-related setting in cups gets turned on by this mere presence...

> Do you have cups-filters installed?
Yes.

> Is there cups_browsed_enable=YES in /etc/rc.conf?
No.

> Check with 'ps xa | grep cups'
  689  -  Is       1:54,46 /opt/sbin/apcupsd --kill-on-powerfail
  815  -  Is       0:00,44 /opt/sbin/cupsd -C /opt/etc/cups/cupsd.conf -s /opt/
 8112  -  I        0:00,02 /opt/libexec/cups/notifier/dbus dbus://

The first line is unrelated. The last line uses the dbus-notifier in question -- I had to rebuild cups with DBUS-enabled.

> or maybe 'service cups_browsed status'.
% service cups_browsed status
Cannot 'status' cups_browsed. Set cups_browsed_enable to YES in /etc/rc.conf or use 'onestatus' instead of 'status'.
% service cups_browsed forcestatus
cups_browsed is not running.
Comment 5 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-08 18:25:10 UTC
> Sorry, I do not understand the above reply... In my case dbus was
> installed normally, when the build of cups was performed.

Same here.

> I suspect, some dbus-related setting in cups gets turned on by this
> mere presence...

I doubt this, because of what I said.  When you build the cups port and then go into /usr/ports/print/cups/work/stage and run 'grep -Ril dbus *' nothing comes up.  No binary calls any dbus function or tries to start PREFIX/libexec/cups/notifier/dbus.

> 8112  -  I        0:00,02 /opt/libexec/cups/notifier/dbus dbus://

This notifier isn't started in my case.  I suspect it is only started when something asks cupsd to be notified of events via D-Bus.  I know that cups-browsed does this, but if you're not running that it must be something else.  Is there anything D-Bus related in your CUPS configuration (grep -Ril dbus PREFIX/etc/cups)?  Do you have any additional printer drivers installed like print/hplip?
Comment 6 Mikhail Teterin freebsd_committer freebsd_triage 2016-08-08 18:36:17 UTC
(In reply to Tijl Coosemans from comment #5)
> Is there anything D-Bus related in your CUPS configuration (grep -Ril dbus PREFIX/etc/cups

Yes, I found it mentioned in /opt/etc/cups/subscriptions.conf:

 Recipient dbus://

But that file is very recent and seems to be auto-generated by cups:

 # Subscription configuration file for CUPS v2.1.3
 # Written by cupsd on 2016-07-30 14:35

> Do you have any additional printer drivers installed like print/hplip?

Not hplip, but there are cups-filters and foomatic. And KDE's print-manager.
Comment 7 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-08 18:53:21 UTC
(In reply to Mikhail Teterin from comment #6)
> Yes, I found it mentioned in /opt/etc/cups/subscriptions.conf:
> 
> Recipient dbus://
> 
> But that file is very recent and seems to be auto-generated by cups:
subscriptions.conf(5) manpage says that file describes active event subscriptions.  Is there anything in there about what requested the dbus subscription?  Can you attach this file to the bug?  Possibly, you can stop cupsd, rename this file and then restart it.

> Not hplip, but there are cups-filters and foomatic. And KDE's print-manager.
Those shouldn't be a problem.
Comment 8 Mikhail Teterin freebsd_committer freebsd_triage 2016-08-08 20:30:16 UTC
Created attachment 173421 [details]
subscriptions.conf

(In reply to Tijl Coosemans from comment #7)
Here is the July 30 version of the file. After I moved it aside and restart cupsd, the new file had no obviously significant differences:

--- /tmp/subscriptions.conf     2016-07-30 14:35:27.619776000 -0400
+++ /opt/etc/cups/subscriptions.conf    2016-08-08 16:26:32.064756000 -0400
-# Subscription configuration file for CUPS v2.1.3
-# Written by cupsd on 2016-07-30 14:35
-NextSubscriptionId 15
-<Subscription 14>
+# Subscription configuration file for CUPS v2.1.4
+# Written by cupsd on 2016-08-08 16:26
+NextSubscriptionId 18
+<Subscription 17>
@@ -10,2 +10,2 @@
-ExpirationTime 1469906310
-NextEventId 1881
+ExpirationTime 1470689777
+NextEventId 39

Hope, this helps.
Comment 9 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-08 20:49:43 UTC
It recreated the dbus:// subscription with DBUS option disabled?
Comment 10 Mikhail Teterin freebsd_committer freebsd_triage 2016-08-08 21:06:45 UTC
(In reply to Tijl Coosemans from comment #9)
> It recreated the dbus:// subscription with DBUS option disabled?

No. I had to enable the DBUS option in order to have a functional system. So it recreated the dbus:// subscription with DBUS option _enabled_.

But without an obvious need for it...
Comment 11 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-08 21:31:39 UTC
The cause could be KDE print manager after all.  I didn't think it would be the cause because I also use KDE and have it installed.  I've never actually used it though and now that I check the code it does use the CUPS D-Bus notifier.  The code is in print/kde4-print-manager/work/print-manager-4.14.3/libkcups/KCupsConnection.cpp.  Did you setup the printer via KDE print manager?  Maybe you can go without DBUS option if you set it up via the CUPS manager at http://localhost:631 instead.
Comment 12 Mikhail Teterin freebsd_committer freebsd_triage 2016-08-09 03:19:24 UTC
(In reply to Tijl Coosemans from comment #11)
I observe the run-away cupsd right after boot -- before anyone even logs-in and starts an X-session. I don't think, KDE's print-manager is active in any way at that time...
Comment 13 Tijl Coosemans freebsd_committer freebsd_triage 2016-08-09 10:20:35 UTC
(In reply to Mikhail Teterin from comment #12)
I suspect that at shutdown the KDE subscription is still active (maybe only sometimes) and then at boot cupsd tries to restore it.  When you install cups without DBUS option you'll have to stop cupsd, clean up subscriptions.conf (or remove it) and then restart cupsd.  I don't know if KDE print manager can work without D-Bus support though.
Comment 14 commit-hook freebsd_committer freebsd_triage 2017-01-12 16:34:07 UTC
A commit references this bug:

Author: tijl
Date: Thu Jan 12 16:33:13 UTC 2017
New revision: 431282
URL: https://svnweb.freebsd.org/changeset/ports/431282

Log:
  The return value of cupsdStartProcess is zero on error.  Fix two cases
  where this is checked incorrectly.

  PR:		211465

Changes:
  head/print/cups/Makefile
  head/print/cups/files/patch-scheduler_client.c
  head/print/cups/files/patch-scheduler_subscriptions.c
Comment 15 Tijl Coosemans freebsd_committer freebsd_triage 2017-01-12 16:47:16 UTC
I had another look at this and committed a fix.  Just a single error message will be logged now when cupsd attempts to send an event to a notifier that is unavailable.