summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOle André Vadla Ravnås <oleavr@gmail.com>2021-11-04 22:48:22 +0100
committerOlivier Crête <olivier.crete@ocrete.ca>2021-11-22 21:53:08 +0000
commit216909011efa8eef6089f311e5046032719c73cb (patch)
treed8692a4f985416283e4fdfecd82dac873f2dc4a6
parent751e8f584cb5fd2d5b1643aed92822df23888bd7 (diff)
downloadlibnice-216909011efa8eef6089f311e5046032719c73cb.tar.gz
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.
-rw-r--r--tests/test-io-stream-common.c2
1 files changed, 2 insertions, 0 deletions
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 ();
}
}