From 6a3b289388c2f1b07b3d07f9ca8518c99129fbe2 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 17 Aug 2009 08:42:34 +0000 Subject: [PATCH] Because taskqueue_run() can drop tq_mutex, we need to check if the TQ_FLAGS_ACTIVE flag wasn't removed in the meantime, which means we missed a wakeup. Approved by: re (kib) --- sys/kern/subr_taskqueue.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index bd4f34d9b9bc..e49c8024ecfc 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -401,6 +401,13 @@ taskqueue_thread_loop(void *arg) TQ_LOCK(tq); while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0) { taskqueue_run(tq); + /* + * Because taskqueue_run() can drop tq_mutex, we need to + * check if the TQ_FLAGS_ACTIVE flag wasn't removed in the + * meantime, which means we missed a wakeup. + */ + if ((tq->tq_flags & TQ_FLAGS_ACTIVE) == 0) + break; TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); }