[systemd-devel] How to unlock a blocking sd_bus_wait() call
Simon McVittie
simon.mcvittie at collabora.co.uk
Fri Jan 8 02:23:22 PST 2016
On 07/01/16 20:15, Iñigo Martínez wrote:
> Do you think that it is a good idea a thread using sd_bus_wait that
> can be cancelled and cleaned later ?
You had a problem and you solved it with threads, and have two now you
problem[Segmentation fault, core dumped.] :-)
If you use an event loop like Lennart suggested (or if you use sd-event
or GLib or something), then you shouldn't need to multi-thread your
socket operations anyway, and D-Bus is basically socket operations.
Based on my experience with libdbus and GDBus, I don't think the
"optionally threaded" design from libdbus is a sensible one. A D-Bus
implementation can either do all its real work in a worker thread and
require message-passing from user code in other threads, like GDBus, or
do all its real work in the caller's thread (and require that each
connection is owned/used by only a single thread), like sd-bus and the
practical recommendation for how to use libdbus reliably. libdbus has
the worst of both worlds - it tries to support arbitrary API calls from
arbitrary threads, which in practice just means it fails to work in
corner cases if you're multi-threading, and has pointless locking
overhead if you're using it single-threaded.
S
--
Simon McVittie
Collabora Ltd. <http://www.collabora.com/>
More information about the systemd-devel
mailing list