summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-24 15:25:34 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-24 17:00:26 +0000
commit6439ab73b3f0fd4e5130f0a561fea822a107d9e7 (patch)
tree70cf6d263d4e98c5d7789c3137b7d0f9ae28d01a
parent909762fd08169a600fa0b30094cc99c9ca617089 (diff)
downloaddbus-6439ab73b3f0fd4e5130f0a561fea822a107d9e7.tar.gz
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 <philip.withnall@collabora.co.uk>
-rw-r--r--test/monitor.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/monitor.c b/test/monitor.c
index 32b7b5dd..69837726 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. */