[Asterisk-code-review] threadpool: Fix potential data race. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Tue May 24 14:29:30 CDT 2016


Corey Farrell has uploaded a new change for review.

  https://gerrit.asterisk.org/2901

Change subject: threadpool: Fix potential data race.
......................................................................

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
---
M main/threadpool.c
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/2901/1

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 @@
 		}
 		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 @@
 	 * 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) {

-- 
To view, visit https://gerrit.asterisk.org/2901
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e33685a5c26fdb300851989a3b82be8c4e03781
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>



More information about the asterisk-code-review mailing list