From: Bart Van Assche Date: Wed, 27 Jul 2011 08:49:47 +0000 (+0000) Subject: Eliminate a superfluous sleep() call and check the pthread_cond_wait() return value X-Git-Tag: svn/VALGRIND_3_7_0~313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abb6befa6db2ba622f964edf0930217d587fa25b;p=thirdparty%2Fvalgrind.git Eliminate a superfluous sleep() call and check the pthread_cond_wait() return value git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11924 --- diff --git a/drd/tests/pth_detached.c b/drd/tests/pth_detached.c index 88d22d9b38..f3025c162e 100644 --- a/drd/tests/pth_detached.c +++ b/drd/tests/pth_detached.c @@ -7,7 +7,7 @@ #include #include -static int s_finished_count; +static int s_finished_count; /* protected by s_mutex */ static pthread_mutex_t s_mutex; static pthread_cond_t s_cond; @@ -70,16 +70,15 @@ int main(int argc, char** argv) // Wait until all detached threads have written their output to stdout. pthread_mutex_lock(&s_mutex); - while (s_finished_count < count1 + count2 - && pthread_cond_wait(&s_cond, &s_mutex) == 0) - ; + while (s_finished_count < count1 + count2) { + const int ret = pthread_cond_wait(&s_cond, &s_mutex); + assert(ret == 0); + } pthread_mutex_unlock(&s_mutex); pthread_cond_destroy(&s_cond); pthread_mutex_destroy(&s_mutex); - sleep(1); - write(STDOUT_FILENO, "\n", 1); return 0;