From: Stefan Metzmacher Date: Fri, 20 Apr 2018 15:12:07 +0000 (+0200) Subject: pthreadpool: don't process further jobs when shutting down X-Git-Tag: ldb-1.5.0~325 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59768416148f72d87cba80ae21afbb2861ca9442;p=thirdparty%2Fsamba.git pthreadpool: don't process further jobs when shutting down Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- 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;