Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167454922
D8012.id20640.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D8012.id20640.diff
View Options
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 (2 << 0)
#define TQ_LOCK(tq) \
do { \
@@ -299,7 +300,10 @@
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);
+ } else if (ticks == 0) {
taskqueue_enqueue_locked(queue, &timeout_task->t);
/* The lock is released inside. */
} else {
@@ -559,8 +563,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
Sat, Aug 22, 9:17 PM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37109339
Default Alt Text
D8012.id20640.diff (1 KB)
Attached To
Mode
D8012: Fix race in taskqueue_drain_timeout()
Attached
Detach File
Event Timeline
Log In to Comment