gtestdbus: Properly close server connections

Otherwise g_test_dbus_down() following a g_test_dbus_stop()
will hang until it times out.

https://bugzilla.gnome.org/show_bug.cgi?id=711807
This commit is contained in:
Stef Walter 2013-11-09 20:18:34 +01:00 committed by Matthias Clasen
parent f16045c9cf
commit baf92d09d6

View File

@ -67,14 +67,15 @@ on_weak_notify_timeout (gpointer user_data)
} }
static gboolean static gboolean
unref_on_idle (gpointer object) dispose_on_idle (gpointer object)
{ {
g_object_run_dispose (object);
g_object_unref (object); g_object_unref (object);
return FALSE; return FALSE;
} }
static gboolean static gboolean
_g_object_unref_and_wait_weak_notify (gpointer object) _g_object_dispose_and_wait_weak_notify (gpointer object)
{ {
WeakNotifyData data; WeakNotifyData data;
guint timeout_id; guint timeout_id;
@ -86,7 +87,7 @@ _g_object_unref_and_wait_weak_notify (gpointer object)
/* Drop the ref in an idle callback, this is to make sure the mainloop /* Drop the ref in an idle callback, this is to make sure the mainloop
* is already running when weak notify happens */ * is already running when weak notify happens */
g_idle_add (unref_on_idle, object); g_idle_add (dispose_on_idle, object);
/* Make sure we don't block forever */ /* Make sure we don't block forever */
timeout_id = g_timeout_add (30 * 1000, on_weak_notify_timeout, &data); timeout_id = g_timeout_add (30 * 1000, on_weak_notify_timeout, &data);
@ -813,7 +814,7 @@ g_test_dbus_down (GTestDBus *self)
stop_daemon (self); stop_daemon (self);
if (connection != NULL) if (connection != NULL)
_g_object_unref_and_wait_weak_notify (connection); _g_object_dispose_and_wait_weak_notify (connection);
g_test_dbus_unset (); g_test_dbus_unset ();
self->priv->up = FALSE; self->priv->up = FALSE;