nick found a race condition in the pthreads test case

svn:r1554
This commit is contained in:
Niels Provos 2009-11-19 22:02:33 +00:00
parent b8f222e055
commit 986500de4d
2 changed files with 4 additions and 1 deletions

View File

@ -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.

View File

@ -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);