From 6c9ac731df4099a061789448d19bcc93d25b0107 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 12 Dec 2017 13:58:48 +0100 Subject: [PATCH] pthreadpool: Add some asserts Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Dec 13 00:44:57 CET 2017 on sn-devel-144 --- lib/pthreadpool/pthreadpool.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/pthreadpool/pthreadpool.c b/lib/pthreadpool/pthreadpool.c index 2dfda38f144..92a88c9ca84 100644 --- a/lib/pthreadpool/pthreadpool.c +++ b/lib/pthreadpool/pthreadpool.c @@ -652,11 +652,13 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id, * Add job to the end of the queue */ if (!pthreadpool_put_job(pool, job_id, fn, private_data)) { - pthread_mutex_unlock(&pool->mutex); + res = pthread_mutex_unlock(&pool->mutex); + assert(res == 0); return ENOMEM; } if (pool->num_idle > 0) { + int unlock_res; /* * We have idle threads, wake one. */ @@ -664,7 +666,8 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id, if (res != 0) { pthreadpool_undo_put_job(pool); } - pthread_mutex_unlock(&pool->mutex); + unlock_res = pthread_mutex_unlock(&pool->mutex); + assert(unlock_res == 0); return res; } @@ -673,7 +676,8 @@ int pthreadpool_add_job(struct pthreadpool *pool, int job_id, /* * No more new threads, we just queue the request */ - pthread_mutex_unlock(&pool->mutex); + res = pthread_mutex_unlock(&pool->mutex); + assert(res == 0); return 0; } -- 2.25.1