kevent: do not check knote lists being empty before removing a knote
If a knote belongs to the list, there is no reason to check for the list emptiness. On the other hand, if the knote does not belong to the list, then checking for emptiness is not enough since there might be a different knote there. Reviewed bu: kevans, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56341
This commit is contained in:
@@ -2953,8 +2953,7 @@ knote_drop_detached(struct knote *kn, struct thread *td)
|
||||
else
|
||||
list = &kq->kq_knhash[KN_HASH(kn->kn_id, kq->kq_knhashmask)];
|
||||
|
||||
if (!SLIST_EMPTY(list))
|
||||
SLIST_REMOVE(list, kn, knote, kn_link);
|
||||
SLIST_REMOVE(list, kn, knote, kn_link);
|
||||
if (kn->kn_status & KN_QUEUED)
|
||||
knote_dequeue(kn);
|
||||
KQ_UNLOCK_FLUX(kq);
|
||||
|
||||
+2
-4
@@ -2668,8 +2668,7 @@ filt_aiodetach(struct knote *kn)
|
||||
|
||||
knl = &kn->kn_ptr.p_aio->klist;
|
||||
knl->kl_lock(knl->kl_lockarg);
|
||||
if (!knlist_empty(knl))
|
||||
knlist_remove(knl, kn, 1);
|
||||
knlist_remove(knl, kn, 1);
|
||||
knl->kl_unlock(knl->kl_lockarg);
|
||||
}
|
||||
|
||||
@@ -2718,8 +2717,7 @@ filt_liodetach(struct knote *kn)
|
||||
|
||||
knl = &kn->kn_ptr.p_lio->klist;
|
||||
knl->kl_lock(knl->kl_lockarg);
|
||||
if (!knlist_empty(knl))
|
||||
knlist_remove(knl, kn, 1);
|
||||
knlist_remove(knl, kn, 1);
|
||||
knl->kl_unlock(knl->kl_lockarg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user