[glib/wip/pwithnall/fix-pollable-test: 3/3] tests: Fix a potential race condition in pollable test
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pwithnall/fix-pollable-test: 3/3] tests: Fix a potential race condition in pollable test
- Date: Tue, 31 May 2022 12:15:56 +0000 (UTC)
commit 95c1d656e23f9bed5ce7de49e05179988b9bc14f
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 31 13:14:15 2022 +0100
tests: Fix a potential race condition in pollable test
This may have been causing an intermittent failure of the pollable test
on BSD, where updating the readable status of a socket takes a bit
longer than on Linux.
```
GLib-GIO-DEBUG: 16:06:41.235: GSocketClient: Starting application layer connection
GLib-GIO-DEBUG: 16:06:41.235: GSocketClient: Connection successful!
Bail out! GLib-GIO:ERROR:../gio/tests/pollable.c:73:check_source_readability_callback: assertion failed
(readable == expected): (0 == 1)
```
I have not debugged the test on BSD, though, so this is only a guess.
See https://gitlab.gnome.org/GNOME/glib/-/jobs/2022087
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gio/tests/pollable.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gio/tests/pollable.c b/gio/tests/pollable.c
index 382d44db66..f52fa32ab8 100644
--- a/gio/tests/pollable.c
+++ b/gio/tests/pollable.c
@@ -90,10 +90,8 @@ write_callback (gpointer user_data)
g_assert_cmpint (nwrote, ==, 2);
g_assert_true (g_pollable_output_stream_is_writable (G_POLLABLE_OUTPUT_STREAM (streams->out)));
-/* Give the pipe a few ticks to propagate the write for sockets. On my
- * iMac i7, 40 works, 30 doesn't. */
- g_usleep (80L);
-
+ /* Wait for the pipe to propagate the write for sockets. */
+ while (!g_pollable_input_stream_is_readable (streams->in));
g_assert_true (g_pollable_input_stream_is_readable (streams->in));
return G_SOURCE_REMOVE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]