-/* $OpenBSD: kern_event.c,v 1.188 2022/05/12 13:33:00 visa Exp $ */
+/* $OpenBSD: kern_event.c,v 1.189 2022/06/12 10:34:36 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
struct kqueue *kq = scan->kqs_kq;
struct knote *kn;
int error = 0, nkev = 0;
+ int reinserted;
if (maxevents == 0)
goto done;
KASSERT(nkev == 0);
error = 0;
+ reinserted = 0;
/* msleep() with PCATCH requires kernel lock. */
KERNEL_LOCK();
kq->kq_count++;
kn->kn_status |= KN_QUEUED;
TAILQ_INSERT_TAIL(&kq->kq_head, kn, kn_tqe);
+ /* Wakeup is done after loop. */
+ reinserted = 1;
}
knote_release(kn);
}
scan->kqs_nevent++;
}
TAILQ_REMOVE(&kq->kq_head, &scan->kqs_start, kn_tqe);
+ if (reinserted && kq->kq_count != 0)
+ kqueue_wakeup(kq);
mtx_leave(&kq->kq_lock);
if (scan->kqs_nevent == 0)
goto retry;