pthreadpool: fix helgrind error in pthreadpool_free()
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Jun 2018 10:40:30 +0000 (12:40 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 12 Jul 2018 12:25:18 +0000 (14:25 +0200)
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 <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/pthreadpool/pthreadpool.c

index 31ff02dd58366aa6d7311972005bf62a38306159..58ea857ded5b0244472e96fac58d0ed2e6d43ff2 100644 (file)
@@ -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);