From d977d4fcd9a1db6084eb469b103e26e797f795d4 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 12 Feb 2016 10:59:44 -0500 Subject: [PATCH] threadpool: Fix potential data race. worker_start checked for ZOMBIE status without holding a lock. All other read/write of worker status are performed with a lock, so this check should do the same. ASTERISK-25777 #close Change-Id: I5e33685a5c26fdb300851989a3b82be8c4e03781 --- main/threadpool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/threadpool.c b/main/threadpool.c index 60e1e9a..d17772e 100644 --- a/main/threadpool.c +++ b/main/threadpool.c @@ -1027,7 +1027,6 @@ static void *worker_start(void *arg) } threadpool_active_thread_idle(worker->pool, worker); } - ast_mutex_unlock(&worker->lock); /* Reaching this portion means the thread is * on death's door. It may have been killed while @@ -1038,7 +1037,10 @@ static void *worker_start(void *arg) * list of zombie threads. */ if (worker->state == ZOMBIE) { + ast_mutex_unlock(&worker->lock); threadpool_zombie_thread_dead(worker->pool, worker); + } else { + ast_mutex_unlock(&worker->lock); } if (worker->options.thread_end) { -- 2.5.0