Re: putting the NM client event loop in a separate thread



On 02/23/2013 01:29 AM, david feeney wrote:
Hi,

My application is getting libdbus segfaults when accessing a few
specific nm functions and I am wondering if it is because I have the nm
client event loop running is a separate thread.

Yes. libdbus is not thread-safe, and by default it integrates with the
default GMainContext.

I *think* you can fix this by creating your own DBusGConnection, with
dbus_g_bus_get_private(), calling dbus_g_connection_get_connection() to
get its DBusConnection, and then calling
dbus_connection_setup_with_g_main() on that to attach it to the
GMainContext you're using in your NM thread. Then create your NMClient with

   client = g_object_new (NM_TYPE_CLIENT,
                          NM_OBJECT_DBUS_CONNECTION, connection,
                          NM_OBJECT_DBUS_PATH, NM_DBUS_PATH,
                          NULL);

(and likewise, pass that bus you nm_remote_settings_new() if you're
using NMRemoteSettings)

-- Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]