diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-20 18:58:55 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-20 18:58:55 +0200 |
commit | a3c99cc476621da1333b1cf0384e3623b3f72b39 (patch) | |
tree | a86bb257cfd3d5c4db7fc50802b0200fba903e0c /threading_pthread.c | |
parent | bc577ef14ecac95a9240b54b49dc0b7939d80804 (diff) |
lock mutex before calling pthread_cond_wait
Diffstat (limited to 'threading_pthread.c')
-rw-r--r-- | threading_pthread.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/threading_pthread.c b/threading_pthread.c index e6b9df9c..00712266 100644 --- a/threading_pthread.c +++ b/threading_pthread.c @@ -180,7 +180,11 @@ int cond_wait (uintptr_t c, uintptr_t m) { pthread_cond_t *cond = (pthread_cond_t *)c; pthread_mutex_t *mutex = (pthread_mutex_t *)m; - int err = pthread_cond_wait (cond, mutex); + int err = mutex_lock (m); + if (err != 0) { + return err; + } + err = pthread_cond_wait (cond, mutex); if (err != 0) { fprintf (stderr, "pthread_cond_wait failed: %s\n", strerror (err)); } |