libdbus or gio dbus for multi-threaded service ?

Daniel P. Berrange dan at berrange.com
Tue Mar 13 10:03:04 UTC 2018


The libvirt project is working on providing a DBus interface proxying to
the libvirt API. Due to the design of the libvirt as a synchronous,
blocking API, the DBus service impl is going to be forced to be multi-
threaded in executing object calls. The initial proof of concept used 
systemd's  sd-dbus library, but that isn't thread safe, so we're 
considering replacing it with either libdbus or GLib's GIO dbus APIs.

Obviously the GIO api provides a higher level abstraction to using DBus
than libdbus does, so that's appealing on its own, but we're particularly
wanting to understand any caveats around multi-thread support/safety with
these options.

Historically since I recall lots of pain around thread safety of libdbus,
but bugzilla [1] suggests much (all ?) of this has been addressed. Though
that bug is still left open, so I wonder what's still unsafe ? Can anyone
clarify this, and any caveats to be aware of in this area. Also what is 
the minimum version of libdbus one should consider if using threads ?

For GIO DBus[2] I'm not finding clear docs about usage with threaded object 
dispatch. Presumably, the implication is that all the DBus protocol I/O 
will still take place via the main event thread, and something like GTask 
would have to be used to execute object dispatch asynchronously by spawning
threads on demand for operations with long execution time.

If anyone has any comments on threaded usage of GIO dbus, or general 
thoughts about the merits of the 2 options we'd appreciate it.

Regards,
Daniel

[1] https://bugs.freedesktop.org/show_bug.cgi?id=54972

[2] https://developer.gnome.org/gio/stable/gdbus-convenience.html
--
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



More information about the dbus mailing list