Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177355184
D8012.1794183070.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D8012.1794183070.diff
View Options
Index: head/share/man/man9/taskqueue.9
===================================================================
--- head/share/man/man9/taskqueue.9
+++ head/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.
+Otherwise the number of pending calls will be returned.
.Pp
The
.Fn taskqueue_cancel
Index: head/sys/kern/subr_taskqueue.c
===================================================================
--- head/sys/kern/subr_taskqueue.c
+++ head/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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 9, 12:11 AM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41600648
Default Alt Text
D8012.1794183070.diff (1 KB)
Attached To
Mode
D8012: Fix race in taskqueue_drain_timeout()
Attached
Detach File
Event Timeline