[Pkg-telepathy-commits] [libnice] 66/265: tests: Remove a potential race from test-thread

Simon McVittie smcv at debian.org
Wed May 14 12:04:53 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 441f0b2257682b74ffccaac82a0c5d54c4eb53ec
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Thu Jan 9 18:02:26 2014 +0000

    tests: Remove a potential race from test-thread
    
    A g_usleep() was introduced in commit
    e22ecb19662970a42def6df74db6359e58084727 to fix a potential race where
    the non-main threads would finish all their work before the error_loop
    was started, leaving the error_loop to run for 30s then abort the test.
    
    A better fix, instead of doing a racy sleep, is to have the non-main
    threads spin until the error_loop is running. GLib takes care of all the
    locking for us, and since we don’t care about efficiency for test cases,
    spinning is fine (the wait is also going to be quite short).
---
 tests/test-thread.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/test-thread.c b/tests/test-thread.c
index 1666d1c..1020645 100644
--- a/tests/test-thread.c
+++ b/tests/test-thread.c
@@ -69,7 +69,9 @@ mainloop_thread (gpointer data)
 {
   GMainLoop *loop = data;
 
-  g_usleep (100000);
+  /* Synchronise thread starting. */
+  while (!g_main_loop_is_running (error_loop));
+
   g_main_loop_run (loop);
 
   return NULL;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list