From fb05d27bb8444cc2e3df32e7619821f3e3c3e857 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 14 Oct 2017 18:27:45 +0200 Subject: 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 --- executor/executor_posix.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'executor/executor_posix.h') 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; } -- cgit mrf-deployment