Skip to content

Commit b9fc7f1

Browse files
committed
cov: threadpool: check destroying and get task under lock
1 parent 82beae6 commit b9fc7f1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/misc/threadpool/threadpool.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,15 @@ lws_threadpool_worker(void *d)
591591
lws_usec_t then;
592592
int n;
593593

594-
if (tp->destroying || !task_to_wsi(task)) {
594+
pthread_mutex_lock(&tp->lock); /* =================== tp lock */
595+
596+
if (tp->destroying || !task_to_wsi(task)) { /* cov */
595597
lwsl_info("%s: stopping on wsi gone\n", __func__);
596598
state_transition(task, LWS_TP_STATUS_STOPPING);
597599
}
598600

601+
pthread_mutex_unlock(&tp->lock); /* --------------- tp unlock */
602+
599603
then = lws_now_usecs();
600604
n = (int)task->args.task(task->args.user, task->status);
601605
lwsl_debug(" %d, status %d\n", n, task->status);

0 commit comments

Comments
 (0)