GDBusConnection: Avoid callbacks on finalized connection
authorDavid Zeuthen <davidz@redhat.com>
Thu, 23 Sep 2010 19:10:50 +0000 (15:10 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Thu, 23 Sep 2010 19:16:56 +0000 (15:16 -0400)
commitf0b04acfd31b768151a88db3f8d3347f55b2a7b3
tree8295b6bcdbbdd047094b348afbbf31776a66eb79
parentc3c0e4d11d0682d832d199de31b35457f6078d5c
GDBusConnection: Avoid callbacks on finalized connection

Turns out that GDBusWorker will issue callbacks (in its own thread)
even after g_dbus_worker_stop() has been called. This would rarely
happen (and unreffing a connection is even rarer) so only saw this bug
occasionally when running the gdbus-connection test case in a loop.

Fix up this issue by maintaining a set of GDBusConnection objects that
are currently "alive" and do nothing in the callbacks if the passed
user_data pointer is not in this set.

Also attempted to fix up a race condition with
_g_object_wait_for_single_ref_do() and its use of GObject toggle
references - for now, just resort to busy waiting, thereby
sidestepping the toggle reference mess altogether.

Signed-off-by: David Zeuthen <davidz@redhat.com>
gio/gdbusconnection.c
gio/gdbusprivate.c
gio/tests/gdbus-connection.c
gio/tests/gdbus-tests.c