sys/kern/kern_event.c
/*
 * knote must already have been detached using the f_detach method.
 * no lock need to be held, it is assumed that the KN_INFLUX flag is set
 * to prevent other removal.
 */
knote must already have been detached using the f_detach method.
no lock need to be held, it is assumed that the KN_INFLUX flag is set
to prevent other removal.
knote must already have been detached using the f_detach method . no lock need to be held it is assumed that the KN_INFLUX flag is set to prevent other removal .
static void
knote_drop(struct knote *kn, struct thread *td)
{
	struct kqueue *kq;
	struct klist *list;
	kq = kn->kn_kq;
	KQ_NOTOWNED(kq);
	KASSERT((kn->kn_status & KN_INFLUX) == KN_INFLUX,
	    ("knote_drop called without KN_INFLUX set in kn_status"));
	KQ_LOCK(kq);
	if (kn->kn_fop->f_isfd)
		list = &kq->kq_knlist[kn->kn_id];
	else
		list = &kq->kq_knhash[KN_HASH(kn->kn_id, kq->kq_knhashmask)];
	if (!SLIST_EMPTY(list))
		SLIST_REMOVE(list, kn, knote, kn_link);
	if (kn->kn_status & KN_QUEUED)
		knote_dequeue(kn);
	KQ_UNLOCK_FLUX(kq);
	if (kn->kn_fop->f_isfd) {
		fdrop(kn->kn_fp, td);
		kn->kn_fp = NULL;
	}
	kqueue_fo_release(kn->kn_kevent.filter);
	kn->kn_fop = NULL;
	knote_free(kn);
}
static void knote_drop ( struct knote * kn , struct thread * td ) { struct kqueue * kq ; struct klist * list ; kq = kn -> kn_kq ; KQ_NOTOWNED ( kq ) ; KASSERT ( ( kn -> kn_status & KN_INFLUX ) == KN_INFLUX , ( " " ) ) ; KQ_LOCK ( kq ) ; if ( kn -> kn_fop -> f_isfd ) list = & kq -> kq_knlist [ kn -> kn_id ] ; else list = & kq -> kq_knhash [ KN_HASH ( kn -> kn_id , kq -> kq_knhashmask ) ] ; if ( ! SLIST_EMPTY ( list ) ) SLIST_REMOVE ( list , kn , knote , kn_link ) ; if ( kn -> kn_status & KN_QUEUED ) knote_dequeue ( kn ) ; KQ_UNLOCK_FLUX ( kq ) ; if ( kn -> kn_fop -> f_isfd ) { fdrop ( kn -> kn_fp , td ) ; kn -> kn_fp = NULL ; } kqueue_fo_release ( kn -> kn_kevent . filter ) ; kn -> kn_fop = NULL ; knote_free ( kn ) ; }
knote must already have been detached using the f_detach method.
knote must already have been detached using the f_detach method .