From 59768416148f72d87cba80ae21afbb2861ca9442 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Apr 2018 17:12:07 +0200 Subject: [PATCH] pthreadpool: don't process further jobs when shutting down Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- lib/pthreadpool/pthreadpool.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/pthreadpool/pthreadpool.c b/lib/pthreadpool/pthreadpool.c index 55ea36ed023..1ef6dccee62 100644 --- a/lib/pthreadpool/pthreadpool.c +++ b/lib/pthreadpool/pthreadpool.c @@ -444,6 +444,10 @@ static void pthreadpool_server_exit(struct pthreadpool *pool) static bool pthreadpool_get_job(struct pthreadpool *p, struct pthreadpool_job *job) { + if (p->shutdown) { + return false; + } + if (p->num_jobs == 0) { return false; } @@ -601,10 +605,9 @@ static void *pthreadpool_server(void *arg) } } - if ((pool->num_jobs == 0) && pool->shutdown) { + if (pool->shutdown) { /* - * No more work to do and we're asked to shut down, so - * exit + * we're asked to shut down, so exit */ pthreadpool_server_exit(pool); return NULL; -- 2.47.3