diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-10-14 18:27:45 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-10-16 14:21:54 +0200 |
| commit | fb05d27bb8444cc2e3df32e7619821f3e3c3e857 (patch) | |
| tree | 2aa5390169aa5f22c720574c0517a8fecc627667 /executor | |
| parent | f0565e623154f63830ab06cc633018259d8be990 (diff) | |
executor: pass attr to pthread_mutex/cond_init
pthread_mutex/cond_init should accept NULL attr,
but Akaros crashes with NULL attr:
https://github.com/brho/akaros/issues/40
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/executor_posix.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/executor/executor_posix.h b/executor/executor_posix.h index e9b06b807..e75bfb3a7 100644 --- a/executor/executor_posix.h +++ b/executor/executor_posix.h @@ -23,10 +23,17 @@ struct event_t { void event_init(event_t* ev) { - if (pthread_mutex_init(&ev->mu, 0)) + // Akaros crashes on NULL attr. + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + if (pthread_mutex_init(&ev->mu, &attr)) fail("pthread_mutex_init failed"); - if (pthread_cond_init(&ev->cv, 0)) + pthread_mutexattr_destroy(&attr); + pthread_condattr_t cvattr; + pthread_condattr_init(&cvattr); + if (pthread_cond_init(&ev->cv, &cvattr)) fail("pthread_cond_init failed"); + pthread_condattr_destroy(&cvattr); ev->state = false; } |
