From: Stefan Metzmacher Date: Thu, 21 Jun 2018 10:40:30 +0000 (+0200) Subject: pthreadpool: fix helgrind error in pthreadpool_free() X-Git-Tag: ldb-1.5.0~330 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1dac71a866857bc70a0477861997cc6174a00d9;p=thirdparty%2Fsamba.git pthreadpool: fix helgrind error in pthreadpool_free() We need to pthread_mutex_lock/unlock the pool mutex before we can destroy it. The following test would trigger this. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/lib/pthreadpool/pthreadpool.c b/lib/pthreadpool/pthreadpool.c index 31ff02dd583..58ea857ded5 100644 --- a/lib/pthreadpool/pthreadpool.c +++ b/lib/pthreadpool/pthreadpool.c @@ -329,6 +329,11 @@ static int pthreadpool_free(struct pthreadpool *pool) ret = pthread_mutex_unlock(&pthreadpools_mutex); assert(ret == 0); + ret = pthread_mutex_lock(&pool->mutex); + assert(ret == 0); + ret = pthread_mutex_unlock(&pool->mutex); + assert(ret == 0); + ret = pthread_mutex_destroy(&pool->mutex); ret1 = pthread_cond_destroy(&pool->condvar); ret2 = pthread_mutex_destroy(&pool->fork_mutex);