GLib:ERROR...

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Sep 2 08:30:13 PDT 2009


On Wed, 02 Sep 2009 at 08:00:30 -0700, nunofaria wrote:
> GLib:ERROR:/build/buildd/glib2.0-2.20.1/glib/gmain.c:1817:g_main_dispatch:
> assertion failed: (current->dispatching_sources == &current_source_link)
> 
> I'm using DBusGmainLoop to connect to pidgin and record any status change,
> these functions are being imported by another file and running on threads.

Sounds familiar: you had a problem to solve, you solved it with threads, and
now you have two problems? :-)

Multi-threading in libdbus is meant to work, although there have been
bugs. Multi-threading in dbus-glib is poorly tested, and I think there are
still some implicit single-thread assumptions in places.

My standard advice for interacting with D-Bus is to do everything in an
asynchronous (event-driven) way, in a mainloop running in your main thread.

If you want to use threads for something else, pass events between the main
(D-Bus) thread and the worker threads via an appropriate thread-safe data
structure, like GAsyncQueue or (if you don't care whether you're portable
beyond Unix) a pipe-to-self.

    Simon


More information about the dbus mailing list