Package: glib2.0 / 2.42.1-1

gdbus-connection-wait-up-to-10s-to-actually-send-a-m.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Tue, 11 Feb 2014 14:23:15 +0000
Subject: [PATCH] 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
Forwarded: yes
---
 gio/tests/gdbus-connection.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/gio/tests/gdbus-connection.c
+++ b/gio/tests/gdbus-connection.c
@@ -1100,10 +1100,13 @@
   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);
@@ -1112,8 +1115,15 @@
   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);