diff options
Diffstat (limited to 'sys/kern/subr_taskqueue.c')
| -rw-r--r-- | sys/kern/subr_taskqueue.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index a10e7107bd89..7758fbdb1a27 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -186,11 +186,14 @@ taskqueue_run(struct taskqueue *queue) STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); pending = task->ta_pending; task->ta_pending = 0; + task->ta_flags |= TAF_PENDING; mtx_unlock(&queue->tq_mutex); task->ta_func(task->ta_context, pending); mtx_lock(&queue->tq_mutex); + task->ta_flags &= ~TAF_PENDING; + wakeup(task); } /* @@ -201,6 +204,17 @@ taskqueue_run(struct taskqueue *queue) mtx_unlock(&queue->tq_mutex); } +void +taskqueue_drain(struct taskqueue *queue, struct task *task) +{ + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "taskqueue_drain"); + mtx_lock(&queue->tq_mutex); + while (task->ta_pending != 0 || (task->ta_flags & TAF_PENDING)) { + msleep(task, &queue->tq_mutex, PWAIT, "-", 0); + } + mtx_unlock(&queue->tq_mutex); +} + static void taskqueue_swi_enqueue(void *context) { |
