From 216909011efa8eef6089f311e5046032719c73cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 4 Nov 2021 22:48:22 +0100 Subject: test-io-stream-common: Avoid CPU starvation by yielding Busy-looping is not a good idea, especially not when run under Valgrind, where such a thread may result in well-behaved threads running thousands of times slower. While passing --fair-sched=yes to Valgrind avoids the issue, it's still better to make our busy-looping less aggressive. --- tests/test-io-stream-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test-io-stream-common.c b/tests/test-io-stream-common.c index b3c12e6..dcd1304 100644 --- a/tests/test-io-stream-common.c +++ b/tests/test-io-stream-common.c @@ -549,6 +549,8 @@ check_for_termination (TestIOStreamThreadData *data, gsize *recv_count, while (*send_count < expected_recv_count) { if (data->callbacks->wait_transmission_cb) { data->callbacks->wait_transmission_cb (data->agent); + } else { + g_thread_yield (); } } -- cgit v1.2.1