X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/fe8ab488e9161c46dd9885d58fc52996dc0249ff..bb59bff194111743b33cc36712410b5656329d3c:/bsd/kern/kern_event.c?ds=sidebyside diff --git a/bsd/kern/kern_event.c b/bsd/kern/kern_event.c index 3b16c4ca0..708aef474 100644 --- a/bsd/kern/kern_event.c +++ b/bsd/kern/kern_event.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include @@ -415,6 +416,7 @@ kqlock2knotedrop(struct kqueue *kq, struct knote *kn) int oktodrop; oktodrop = ((kn->kn_status & (KN_DROPPING | KN_ATTACHING)) == 0); + kn->kn_status &= ~KN_STAYQUEUED; kn->kn_status |= KN_DROPPING; if (oktodrop) { if (kn->kn_inuse == 0) { @@ -1180,6 +1182,7 @@ kqueue_alloc(struct proc *p) kq->kq_p = p; } else { FREE_ZONE(kq, sizeof (struct kqueue), M_KQUEUE); + kq = NULL; } } @@ -2624,10 +2627,7 @@ knote_unlink_wait_queue(struct knote *kn, struct wait_queue *wq, wait_queue_link kern_return_t kr; kr = wait_queue_unlink_nofree(wq, kq->kq_wqs, wqlp); - kqlock(kq); - kn->kn_status &= ~KN_STAYQUEUED; - knote_dequeue(kn); - kqunlock(kq); + knote_clearstayqueued(kn); return ((kr != KERN_SUCCESS) ? EINVAL : 0); } @@ -3517,3 +3517,12 @@ knote_markstayqueued(struct knote *kn) knote_enqueue(kn); kqunlock(kn->kn_kq); } + +void +knote_clearstayqueued(struct knote *kn) +{ + kqlock(kn->kn_kq); + kn->kn_status &= ~KN_STAYQUEUED; + knote_dequeue(kn); + kqunlock(kn->kn_kq); +}