Skip to content

Commit 111dc6d

Browse files
committed
cov: threadpool: lock during destruction
1 parent fd3bc75 commit 111dc6d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

lib/misc/threadpool/threadpool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ lws_threadpool_destroy(struct lws_threadpool *tp)
826826
#if defined(WIN32)
827827
Sleep(1000);
828828
#endif
829+
pthread_mutex_lock(&tp->lock); /* ======================== tpool lock */
829830

830831
task = tp->task_done_head;
831832
while (task) {
@@ -835,6 +836,8 @@ lws_threadpool_destroy(struct lws_threadpool *tp)
835836
task = next;
836837
}
837838

839+
pthread_mutex_unlock(&tp->lock); /* -------------------- tpool unlock */
840+
838841
pthread_mutex_destroy(&tp->lock);
839842

840843
memset(tp, 0xdd, sizeof(*tp));

0 commit comments

Comments
 (0)