From 6439ab73b3f0fd4e5130f0a561fea822a107d9e7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 24 Feb 2015 15:25:34 +0000 Subject: [PATCH] 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 --- test/monitor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/monitor.c b/test/monitor.c index 32b7b5d..6983772 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. */ -- 2.7.4