Skip to content
Snippets Groups Projects
Commit 80ff2c25 authored by Corey Farrell's avatar Corey Farrell
Browse files

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
parent 56f24345
No related branches found
No related tags found
No related merge requests found
...@@ -1012,6 +1012,7 @@ static void worker_thread_destroy(void *obj) ...@@ -1012,6 +1012,7 @@ static void worker_thread_destroy(void *obj)
static void *worker_start(void *arg) static void *worker_start(void *arg)
{ {
struct worker_thread *worker = arg; struct worker_thread *worker = arg;
enum worker_state saved_state;
if (worker->options.thread_start) { if (worker->options.thread_start) {
worker->options.thread_start(); worker->options.thread_start();
...@@ -1027,6 +1028,7 @@ static void *worker_start(void *arg) ...@@ -1027,6 +1028,7 @@ static void *worker_start(void *arg)
} }
threadpool_active_thread_idle(worker->pool, worker); threadpool_active_thread_idle(worker->pool, worker);
} }
saved_state = worker->state;
ast_mutex_unlock(&worker->lock); ast_mutex_unlock(&worker->lock);
/* Reaching this portion means the thread is /* Reaching this portion means the thread is
...@@ -1037,7 +1039,7 @@ static void *worker_start(void *arg) ...@@ -1037,7 +1039,7 @@ static void *worker_start(void *arg)
* that the thread can be removed from the * that the thread can be removed from the
* list of zombie threads. * list of zombie threads.
*/ */
if (worker->state == ZOMBIE) { if (saved_state == ZOMBIE) {
threadpool_zombie_thread_dead(worker->pool, worker); threadpool_zombie_thread_dead(worker->pool, worker);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment