From: Niels Provos Date: Thu, 19 Nov 2009 22:02:33 +0000 (+0000) Subject: nick found a race condition in the pthreads test case X-Git-Tag: release-2.0.3-alpha~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=986500de4db591134832923f5dd8d78477a62f2e;p=libevent nick found a race condition in the pthreads test case svn:r1554 --- diff --git a/ChangeLog b/ChangeLog index be01b27b..7b2f34ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,7 @@ Changes in 2.0.3-alpha: o Finally expose the IOCP-based bufferevent backend. It passes its unit tests, but probably still has some bugs remaining. Code by Nick Mathewson and Christopher Davis. o Numerous other bugfixes. o On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback. + o Fix a race condition in the pthreads test case; found by Nick Mathewson Changes in 2.0.2-alpha: o Add a new flag to bufferevents to make all callbacks automatically deferred. diff --git a/test/regress_pthread.c b/test/regress_pthread.c index acfd4327..bc611d0f 100644 --- a/test/regress_pthread.c +++ b/test/regress_pthread.c @@ -73,9 +73,11 @@ basic_thread(void *arg) for (i = 0; i < 100; i++) { struct timeval tv; evutil_timerclear(&tv); - assert(evtimer_add(&ev, &tv) == 0); assert(pthread_mutex_lock(&cw.lock) == 0); + /* we need to make sure that even does not happen before + * we get to wait on the conditional variable */ + assert(evtimer_add(&ev, &tv) == 0); assert(pthread_cond_wait(&cw.cond, &cw.lock) == 0); assert(pthread_mutex_unlock(&cw.lock) == 0);