-/* $OpenBSD: kern_event.c,v 1.166 2021/06/11 04:29:54 visa Exp $ */
+/* $OpenBSD: kern_event.c,v 1.167 2021/06/16 14:26:30 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
void
filt_procdetach(struct knote *kn)
{
+ struct kqueue *kq = kn->kn_kq;
struct process *pr = kn->kn_ptr.p_process;
- int s;
+ int s, status;
+
+ mtx_enter(&kq->kq_lock);
+ status = kn->kn_status;
+ mtx_leave(&kq->kq_lock);
- if (kn->kn_status & KN_DETACHED)
+ if (status & KN_DETACHED)
return;
s = splhigh();
int
filt_proc(struct knote *kn, long hint)
{
+ struct kqueue *kq = kn->kn_kq;
u_int event;
/*
struct process *pr = kn->kn_ptr.p_process;
int s;
- s = splhigh();
+ mtx_enter(&kq->kq_lock);
kn->kn_status |= KN_DETACHED;
+ mtx_leave(&kq->kq_lock);
+
+ s = splhigh();
kn->kn_flags |= (EV_EOF | EV_ONESHOT);
kn->kn_data = W_EXITCODE(pr->ps_xexit, pr->ps_xsig);
klist_remove_locked(&pr->ps_klist, kn);
kev.fflags = kn->kn_sfflags;
kev.data = kn->kn_id; /* parent */
kev.udata = kn->kn_udata; /* preserve udata */
- error = kqueue_register(kn->kn_kq, &kev, NULL);
+ error = kqueue_register(kq, &kev, NULL);
if (error)
kn->kn_fflags |= NOTE_TRACKERR;
}
-/* $OpenBSD: event.h,v 1.55 2021/06/02 13:56:28 visa Exp $ */
+/* $OpenBSD: event.h,v 1.56 2021/06/16 14:26:30 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
* Locking:
* I immutable after creation
* o object lock
+ * q kn_kq->kq_lock
*/
struct knote {
SLIST_ENTRY(knote) kn_link; /* for fd */
TAILQ_ENTRY(knote) kn_tqe;
struct kqueue *kn_kq; /* [I] which queue we are on */
struct kevent kn_kevent;
- int kn_status;
+ int kn_status; /* [q] */
int kn_sfflags; /* [o] saved filter flags */
__int64_t kn_sdata; /* [o] saved data field */
union {