[systemd-devel] [systemd-level]: How to share the same DBUS between the main process and the new thread?
Lennart Poettering
lennart at poettering.net
Thu Apr 23 13:49:54 UTC 2020
On Do, 23.04.20 21:31, www (ouyangxuan10 at 163.com) wrote:
> Dear all,
>
>
> I write a new service and the service need wait the signal. At the same time, I need to start a new thread to get information. If the two share the same DBUS, the following problems will arise:
> terminate called after throwing an instance of 'sdbusplus::exception::SdBusError'
> what(): sd_bus_call: org.freedesktop.DBus.Error.Timeout: Connection timed out
>
>
> Is there any good way to solve this problem?
> (I don't want to create a new DBUS in a new thread.)
sd-bus is not thread-safe. Use a seprate connection for each
thread. You cannot share connections between multiple shares (unless
of course, you lock around it yourself)
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list