summaryrefslogtreecommitdiff
path: root/main/threadpool.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2016-02-12 10:59:44 -0500
committerCorey Farrell <git@cfware.com>2016-05-24 15:40:21 -0500
commit80ff2c2540544123b1cf040f1a651cbde4ab4e14 (patch)
tree21d13b28b43e899038b824c373a9d6ef5b228557 /main/threadpool.c
parent56f24345f7f0ccf44d3edec69a07493503dec4fe (diff)
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
Diffstat (limited to 'main/threadpool.c')
-rw-r--r--main/threadpool.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/main/threadpool.c b/main/threadpool.c
index 60e1e9a3b..9cd33ab1a 100644
--- a/main/threadpool.c
+++ b/main/threadpool.c
@@ -1012,6 +1012,7 @@ static void worker_thread_destroy(void *obj)
static void *worker_start(void *arg)
{
struct worker_thread *worker = arg;
+ enum worker_state saved_state;
if (worker->options.thread_start) {
worker->options.thread_start();
@@ -1027,6 +1028,7 @@ static void *worker_start(void *arg)
}
threadpool_active_thread_idle(worker->pool, worker);
}
+ saved_state = worker->state;
ast_mutex_unlock(&worker->lock);
/* Reaching this portion means the thread is
@@ -1037,7 +1039,7 @@ static void *worker_start(void *arg)
* that the thread can be removed from the
* list of zombie threads.
*/
- if (worker->state == ZOMBIE) {
+ if (saved_state == ZOMBIE) {
threadpool_zombie_thread_dead(worker->pool, worker);
}