unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9581: 24.0.50; dbus-unregister-object fails if service is nil
@ 2011-09-22 23:01 Julien Danjou
  2011-09-23 15:37 ` Michael Albinus
  0 siblings, 1 reply; 12+ messages in thread
From: Julien Danjou @ 2011-09-22 23:01 UTC (permalink / raw)
  To: 9581

If you use `dbus-register-signal' with a nil SERVICE value, like:

      (dbus-register-signal :session nil
                            "/org/gtk/Private/RemoteVolumeMonitor"
                            "org.gtk.Private.RemoteVolumeMonitor" "VolumeAdded"
                            'identity)

This is valid and works fine. However, on unregister it fails:
Debugger entered--Lisp error: (dbus-error "Call to ReleaseName has wrong args (b, expected s)")
  dbus-call-method(:session "org.freedesktop.DBus" "/org/freedesktop/DBus" "org.freedesktop.DBus" "ReleaseName" nil)
  dbus-unregister-object(((:session "org.gtk.Private.RemoteVolumeMonitor" "VolumeAdded") (nil "/org/gtk/Private/RemoteVolumeMonitor" identity)))

Why does it fail? Because of the following code in
`dbus-unregister-object':

#+begin_src emacs-lisp
	(unless found
	  (dbus-call-method
	   bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus
	   "ReleaseName" service))))
+end_src

And here service is… nil. Which is translated to a boolean (b) but
should be a string (s).

But honestly, I'm not sure what the good fix is. To me, this code is
totally wrong in such a case.

When using `dbus-register-signal', this happens:
1. the dbus_bus_add_match() function is called to add a match on the bus
2. the (match callback) pair is recorded into
   `dbus-registered-objets-table' 

This makes things work. When a signal happens, something is looking into
`dbus-registered-objets-table' and call the callback function.

But to stop listening for a signal, the function to use is
`dbus-unregister-object', and it is doing this:
1. remove the (match callback) pair from `dbus-registered-objets-table'
2. call ReleaseName on the service we were listening

While I agree on point 1., the point 2. is totally irrelevant in such a
case. There's no need to do such a thing, the name has never been
requested with RequestName before.

I think that:
- step 2 should be removed or another function should be created which
  does not send a ReleaseName
- dbus_bus_remove_match() should be used to remove the watch from the
  bus, which would be a lot cleaner.

-- 
Julien Danjou





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-09-26 13:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-22 23:01 bug#9581: 24.0.50; dbus-unregister-object fails if service is nil Julien Danjou
2011-09-23 15:37 ` Michael Albinus
2011-09-23 16:12   ` Julien Danjou
2011-09-24 11:50     ` Michael Albinus
2011-09-24 14:19       ` Julien Danjou
2011-09-24 14:37         ` Michael Albinus
2011-09-25 11:38           ` Julien Danjou
2011-09-25 11:59             ` Michael Albinus
2011-09-25 12:19               ` Julien Danjou
2011-09-25 16:03                 ` Michael Albinus
2011-09-26 12:16                   ` Julien Danjou
2011-09-26 13:57                     ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).