summaryrefslogtreecommitdiffstats
path: root/sys/sys/_task.h
diff options
context:
space:
mode:
authorzml <zml@FreeBSD.org>2010-04-30 16:29:05 +0000
committerzml <zml@FreeBSD.org>2010-04-30 16:29:05 +0000
commit3eac0000f02cd2cb160464ae01b04fe3415e4b60 (patch)
treee93cf5353c02643df797316682ae4b711e713702 /sys/sys/_task.h
parent96ebc710b900ffe0a980b10e539b88278805741c (diff)
downloadFreeBSD-src-3eac0000f02cd2cb160464ae01b04fe3415e4b60.zip
FreeBSD-src-3eac0000f02cd2cb160464ae01b04fe3415e4b60.tar.gz
Handle taskqueue_drain(9) correctly on a threaded taskqueue:
taskqueue_drain(9) will not correctly detect whether a task is currently running. The check is against a field in the taskqueue struct, but for a threaded queue with more than one thread, multiple threads can simultaneously be running a task, thus stomping over the tq_running field. Submitted by: Matthew Fleming <matthew.fleming@isilon.com> Reviewed by: jhb Approved by: dfr (mentor)
Diffstat (limited to 'sys/sys/_task.h')
-rw-r--r--sys/sys/_task.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/sys/_task.h b/sys/sys/_task.h
index 2a51e1b..781cd48 100644
--- a/sys/sys/_task.h
+++ b/sys/sys/_task.h
@@ -36,15 +36,21 @@
* taskqueue_run(). The first argument is taken from the 'ta_context'
* field of struct task and the second argument is a count of how many
* times the task was enqueued before the call to taskqueue_run().
+ *
+ * List of locks
+ * (c) const after init
+ * (q) taskqueue lock
*/
typedef void task_fn_t(void *context, int pending);
struct task {
- STAILQ_ENTRY(task) ta_link; /* link for queue */
- u_short ta_pending; /* count times queued */
- u_short ta_priority; /* Priority */
- task_fn_t *ta_func; /* task handler */
- void *ta_context; /* argument for handler */
+ STAILQ_ENTRY(task) ta_link; /* (q) link for queue */
+ u_int ta_flags; /* (q) state of this task */
+#define TA_FLAGS_RUNNING 0x01
+ u_short ta_pending; /* (q) count times queued */
+ u_short ta_priority; /* (c) Priority */
+ task_fn_t *ta_func; /* (c) task handler */
+ void *ta_context; /* (c) argument for handler */
};
#endif /* !_SYS__TASK_H_ */
OpenPOWER on IntegriCloud