From: Simon McVittie Date: Tue, 24 Feb 2015 15:25:34 +0000 (+0000) Subject: monitor test: don't block in main context if we already have messages X-Git-Tag: dbus-1.9.14~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6439ab73b3f0fd4e5130f0a561fea822a107d9e7;p=thirdparty%2Fdbus.git monitor test: don't block in main context if we already have messages Functions like become_monitor() sometimes iterate the main context, which could leave us with unprocessed messages in f->monitored. We need to drain that queue of unprocessed messages (setting flags accordingly, which might meet the loop's exit condition or cause a break) before we are willing to block in the main context again. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89222 Reviewed-by: Philip Withnall --- diff --git a/test/monitor.c b/test/monitor.c index 32b7b5dd3..698377265 100644 --- a/test/monitor.c +++ b/test/monitor.c @@ -541,7 +541,8 @@ test_become_monitor (Fixture *f, while (!got_unique || !got_a || !got_b || !got_c) { - test_main_context_iterate (f->ctx, TRUE); + if (g_queue_is_empty (&f->monitored)) + test_main_context_iterate (f->ctx, TRUE); while ((m = g_queue_pop_head (&f->monitored)) != NULL) { @@ -596,7 +597,8 @@ test_become_monitor (Fixture *f, while (!lost_unique || !lost_a || !lost_b || !lost_c) { - test_main_context_iterate (f->ctx, TRUE); + if (g_queue_is_empty (&f->monitored)) + test_main_context_iterate (f->ctx, TRUE); while ((m = g_queue_pop_head (&f->monitored)) != NULL) { @@ -651,7 +653,8 @@ test_become_monitor (Fixture *f, while (TRUE) { - test_main_context_iterate (f->ctx, TRUE); + if (g_queue_is_empty (&f->monitored)) + test_main_context_iterate (f->ctx, TRUE); /* When we iterate all the connection's messages, we see ourselves * losing all our names, then we're disconnected. */