summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_taskqueue.c
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-10-12 11:41:26 -0300
committerRenato Botelho <renato@netgate.com>2016-10-12 11:41:26 -0300
commitcb642130dfc50717bb970a104c44aa7690930a38 (patch)
treec67f108534217a209198c6b201949ecc73acaba3 /sys/kern/subr_taskqueue.c
parent5dd7ab172435dc99e1abc1f7d73fd5e720050bbc (diff)
parentcd04fbc5e631c6b3e80a14eb7044c3be35fba2d2 (diff)
downloadFreeBSD-src-cb642130dfc50717bb970a104c44aa7690930a38.zip
FreeBSD-src-cb642130dfc50717bb970a104c44aa7690930a38.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
Diffstat (limited to 'sys/kern/subr_taskqueue.c')
-rw-r--r--sys/kern/subr_taskqueue.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index 5a20148..d380b9c 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -81,6 +81,7 @@ struct taskqueue {
#define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2)
#define DT_CALLOUT_ARMED (1 << 0)
+#define DT_DRAIN_IN_PROGRESS (1 << 1)
#define TQ_LOCK(tq) \
do { \
@@ -299,7 +300,11 @@ taskqueue_enqueue_timeout(struct taskqueue *queue,
KASSERT(!queue->tq_spin, ("Timeout for spin-queue"));
timeout_task->q = queue;
res = timeout_task->t.ta_pending;
- if (ticks == 0) {
+ if (timeout_task->f & DT_DRAIN_IN_PROGRESS) {
+ /* Do nothing */
+ TQ_UNLOCK(queue);
+ res = -1;
+ } else if (ticks == 0) {
taskqueue_enqueue_locked(queue, &timeout_task->t);
/* The lock is released inside. */
} else {
@@ -559,8 +564,24 @@ taskqueue_drain_timeout(struct taskqueue *queue,
struct timeout_task *timeout_task)
{
+ /*
+ * Set flag to prevent timer from re-starting during drain:
+ */
+ TQ_LOCK(queue);
+ KASSERT((timeout_task->f & DT_DRAIN_IN_PROGRESS) == 0,
+ ("Drain already in progress"));
+ timeout_task->f |= DT_DRAIN_IN_PROGRESS;
+ TQ_UNLOCK(queue);
+
callout_drain(&timeout_task->c);
taskqueue_drain(queue, &timeout_task->t);
+
+ /*
+ * Clear flag to allow timer to re-start:
+ */
+ TQ_LOCK(queue);
+ timeout_task->f &= ~DT_DRAIN_IN_PROGRESS;
+ TQ_UNLOCK(queue);
}
static void
OpenPOWER on IntegriCloud