[next] telepathy-glib: dbus test: delay re-entering main loop to request/ release names into an idle
Simon McVittie
smcv at kemper.freedesktop.org
Thu Mar 13 07:08:35 PDT 2014
Module: telepathy-glib
Branch: next
Commit: c26d3e777bb767a228d580a921ea4cf158716ee8
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=c26d3e777bb767a228d580a921ea4cf158716ee8
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Mon Mar 10 16:32:51 2014 +0000
dbus test: delay re-entering main loop to request/release names into an idle
GDBus guarantees that it will alternate signalling names appearing
and vanishing, and this reentrant usage probably breaks that.
It was a terrible idea anyway.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76000
Reviewed-by: Guillaume Desmottes
---
tests/dbus/dbus.c | 86 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 63 insertions(+), 23 deletions(-)
diff --git a/tests/dbus/dbus.c b/tests/dbus/dbus.c
index d955b49..925b9f6 100644
--- a/tests/dbus/dbus.c
+++ b/tests/dbus/dbus.c
@@ -137,6 +137,56 @@ static GMainLoop *mainloop;
static gchar *two = "2", *five = "5";
static gboolean had_owners = FALSE;
+static gboolean
+request_names (gpointer obj)
+{
+ GError *error = NULL;
+ guint ret;
+ gboolean ok;
+
+ ok = tp_cli_dbus_daemon_run_request_name (obj, -1,
+ "com.example", 0, &ret, &error, NULL);
+ g_assert_no_error (error);
+ g_assert (ok);
+ g_assert_cmpuint (ret, ==, 1);
+
+ ok = tp_cli_dbus_daemon_run_request_name (obj, -1,
+ "org.example", 0, &ret, &error, NULL);
+ g_assert_no_error (error);
+ g_assert (ok);
+ g_assert_cmpuint (ret, ==, 1);
+
+ ok = tp_cli_dbus_daemon_run_request_name (obj, -1,
+ "net.example", 0, &ret, &error, NULL);
+ g_assert_no_error (error);
+ g_assert (ok);
+ g_assert_cmpuint (ret, ==, 1);
+
+ return FALSE;
+}
+
+static gboolean
+release_names (gpointer obj)
+{
+ GError *error = NULL;
+ guint ret;
+ gboolean ok;
+
+ ok = tp_cli_dbus_daemon_run_release_name (obj, -1,
+ "org.example", &ret, &error, NULL);
+ g_assert_no_error (error);
+ g_assert (ok);
+ g_assert_cmpuint (ret, ==, 1);
+
+ ok = tp_cli_dbus_daemon_run_release_name (obj, -1,
+ "net.example", &ret, &error, NULL);
+ g_assert_no_error (error);
+ g_assert (ok);
+ g_assert_cmpuint (ret, ==, 1);
+
+ return FALSE;
+}
+
static void
noc (TpDBusDaemon *obj,
const gchar *name,
@@ -163,33 +213,23 @@ noc (TpDBusDaemon *obj,
}
else
{
- guint ret;
- GError *error = NULL;
-
- g_assert (tp_cli_dbus_daemon_run_request_name (obj, -1,
- "com.example", 0, &ret, &error, NULL));
- g_assert (ret == 1 && error == NULL);
- g_assert (tp_cli_dbus_daemon_run_request_name (obj, -1,
- "org.example", 0, &ret, &error, NULL));
- g_assert (ret == 1 && error == NULL);
- g_assert (tp_cli_dbus_daemon_run_request_name (obj, -1,
- "net.example", 0, &ret, &error, NULL));
- g_assert (ret == 1 && error == NULL);
+ /* do it in an idle: re-entering this same watch callback
+ * doesn't seem to work under GDBus, and it was a terrible
+ * idea anyway */
+ g_idle_add_full (G_PRIORITY_DEFAULT,
+ request_names, g_object_ref (obj), g_object_unref);
}
}
else
{
- guint ret;
- GError *error = NULL;
-
- g_assert (tp_dbus_daemon_cancel_name_owner_watch (obj,
- "org.example", noc, five));
- g_assert (tp_cli_dbus_daemon_run_release_name (obj, -1,
- "org.example", &ret, &error, NULL));
- g_assert (ret == 1 && error == NULL);
- g_assert (tp_cli_dbus_daemon_run_release_name (obj, -1,
- "net.example", &ret, &error, NULL));
- g_assert (ret == 1 && error == NULL);
+ gboolean ok;
+
+ ok = tp_dbus_daemon_cancel_name_owner_watch (obj,
+ "org.example", noc, five);
+ g_assert (ok);
+
+ g_idle_add_full (G_PRIORITY_DEFAULT,
+ release_names, g_object_ref (obj), g_object_unref);
}
}
}
More information about the telepathy-commits
mailing list