[glib] gdbus-connection: wait up to 10s to actually send a message
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gdbus-connection: wait up to 10s to actually send a message
- Date: Thu, 14 May 2015 11:42:02 +0000 (UTC)
commit 3beb67f9f3b1db6ee133973edfd89df89d7bdde5
Author: Simon McVittie <simon mcvittie collabora co uk>
Date: Tue Feb 11 14:23:15 2014 +0000
gdbus-connection: wait up to 10s to actually send a message
We previously waited 0.25s, which should be enough even on slow machines,
but you never know; but we also now wait in 0.1s increments, so this test
should actually be faster now.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=724113
Acked-by: Matthias Clasen <mclasen redhat com>
gio/tests/gdbus-connection.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c
index 015524c..488f213 100644
--- a/gio/tests/gdbus-connection.c
+++ b/gio/tests/gdbus-connection.c
@@ -1115,10 +1115,13 @@ send_bogus_message (GDBusConnection *c, guint32 *out_serial)
g_object_unref (m);
}
+#define SLEEP_USEC (100 * 1000)
+
static gpointer
serials_thread_func (GDBusConnection *c)
{
guint32 message_serial;
+ guint i;
/* No calls on this thread yet */
g_assert_cmpint (g_dbus_connection_get_last_serial(c), ==, 0);
@@ -1127,8 +1130,15 @@ serials_thread_func (GDBusConnection *c)
message_serial = 0;
send_bogus_message (c, &message_serial);
- /* Give it some time to actually send the message out */
- g_usleep (250000);
+ /* Give it some time to actually send the message out. 10 seconds
+ * should be plenty, even on slow machines. */
+ for (i = 0; i < 10 * G_USEC_PER_SEC / SLEEP_USEC; i++)
+ {
+ if (g_dbus_connection_get_last_serial(c) != 0)
+ break;
+
+ g_usleep (SLEEP_USEC);
+ }
g_assert_cmpint (g_dbus_connection_get_last_serial(c), !=, 0);
g_assert_cmpint (g_dbus_connection_get_last_serial(c), ==, message_serial);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]