Using d-bus from multiple threads?

Ivan Barr itb.wrk at
Mon Aug 23 08:39:58 PDT 2010

Hi folks,

I have an application which has two threads. One thread receives requests
and as a result makes d-bus method calls to a server. The other thread is a
glib MainLoop which listens for signals coming in from the server (and may
as a consequent make further d-bus method calls).

Intermittently I am getting mysterious crashes which seem to be coming from
dbus. Sometimes the application can run for a couple of hours before this

Are there any guidelines to follow when using d-bus from multiple threads? I
feel like I'm working somewhat in the dark!

My latest attempt to fix this is to change the application to use a separate
private connection for each thread by doing this:

conn1 = dbus_g_bus_get_private(DBUS_
conn2 = dbus_g_bus_get_private(DBUS_BUS_SESSION, NULL, &error);

Each thread only ever uses proxies created on it's connection.

I am also calling the following (which I presume are required if using the
library from threads):


The main loop is started as follows:

        main_loop = g_main_loop_new(NULL, TRUE);

Does this seem like a reasonable approach?

It would be great to understand the limitations of using d-bus from
threads... The version of libdbus-glib I'm using is 2.1.0 and libdbus is

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the dbus mailing list