Page MenuHomeFreeBSD

D8012.id20696.diff
No OneTemporary

D8012.id20696.diff

Index: share/man/man9/taskqueue.9
===================================================================
--- share/man/man9/taskqueue.9
+++ share/man/man9/taskqueue.9
@@ -223,6 +223,8 @@
after the absolute value of
.Va ticks
is passed.
+This function will return -1 if the queue is being drained.
+Else the number of pending calls will be returned.
.Pp
The
.Fn taskqueue_cancel
Index: sys/kern/subr_taskqueue.c
===================================================================
--- sys/kern/subr_taskqueue.c
+++ sys/kern/subr_taskqueue.c
@@ -81,6 +81,7 @@
#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 @@
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 @@
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

File Metadata

Mime Type
text/plain
Expires
Sat, Aug 22, 9:17 PM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37109358
Default Alt Text
D8012.id20696.diff (1 KB)

Event Timeline