Subject: Re: bug#11415: 24.1.50; Dbus hangs indefinitely during batch mode & daemon startup

From: Michael Albinus <[email-masked]>
Date: Sun, 06 May 2012 12:59:54 +0200

"Ryan C. Thompson" <[email-masked]> writes:

> It seems that during the startup of any emacs without a terminal
> (i.e. "--batch" or "--daemon"), recent emacs snapshots cannot make dbus
> calls. Worse, any attempt to make a dbus call will hang
> indefinitely. This stops me from being able to use some of my config in
> emacs, since it is dbus based and cannot be loaded on startup in daemon
> mode.
>
> Specifically, I can easily reproduce the bug like this:
>
> emacs-snapshot -Q --batch -l dbus --eval '(message
>  "DBus system names: %s"
>  (dbus-call-method :system dbus-service-dbus
>   dbus-path-dbus dbus-interface-dbus "ListNames"))'

In Emacs 24.1.50, `dbus-call-method' changed from a synchronous call to
an asynchronous one (see etc/NEWS). If Emacs runs in batch mode, it
doesn't seem to read incoming events. Therefore, the return event of the
call is not read.

I will see what can be done. Either we must enable Emacs to receive some
special input events also in batch mode. Or we must check inside
`dbus-call-method', whether Emacs runs daemonized, and use the blocking
call then.

I would prefer the first alternative, because receiving D-Bus signals and
running Emacs as D-Bus enabled server does not work either when Emacs
does not accept incoming events.

> There is no backtrace or anything, because the dbus call never
> returns.

In theory, it shall accept at least timeouts, like 

emacs -Q --daemon -l dbus --eval \
  '(message "DBus system names: %s" \
     (dbus-call-method \
      :system dbus-service-dbus dbus-path-dbus dbus-interface-dbus \
      "ListNames" :timeout 5000))'

But it doesn't, which is another bug to be fixed.

Best regards, Michael.