Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150281476
D31772.id94496.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
963 B
Referenced Files
None
Subscribers
None
D31772.id94496.diff
View Options
Index: sys/kern/kern_event.c
===================================================================
--- sys/kern/kern_event.c
+++ sys/kern/kern_event.c
@@ -859,14 +859,24 @@
{
struct kq_timer_cb_data *kc;
unsigned int old __unused;
+ bool pending;
kc = kn->kn_ptr.p_v;
- callout_drain(&kc->c);
- if ((kc->flags & KQ_TIMER_CB_ENQUEUED) != 0) {
+ do {
+ callout_drain(&kc->c);
+
+ /*
+ * kqtimer_proc_continue() might have rescheduled this callout.
+ * Double-check, using the process mutex as an interlock.
+ */
PROC_LOCK(kc->p);
- TAILQ_REMOVE(&kc->p->p_kqtim_stop, kc, link);
+ if ((kc->flags & KQ_TIMER_CB_ENQUEUED) != 0) {
+ kc->flags &= ~KQ_TIMER_CB_ENQUEUED;
+ TAILQ_REMOVE(&kc->p->p_kqtim_stop, kc, link);
+ }
+ pending = callout_pending(&kc->c);
PROC_UNLOCK(kc->p);
- }
+ } while (pending);
free(kc, M_KQUEUE);
old = atomic_fetchadd_int(&kq_ncallouts, -1);
KASSERT(old > 0, ("Number of callouts cannot become negative"));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 31, 8:43 PM (5 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30648421
Default Alt Text
D31772.id94496.diff (963 B)
Attached To
Mode
D31772: kevent: Fix races between timer detach and kqtimer_proc_continue()
Attached
Detach File
Event Timeline
Log In to Comment