created | 2021-12-07T15:10:17Z |
---|---|
begin | 2021-11-29T15:39:59Z |
end | 2021-11-29T15:54:04Z |
path | src/sys |
commits | 1 |
date | 2021-11-29T15:54:04Z | |||
---|---|---|---|---|
author | visa | |||
files | src/sys/kern/kern_event.c | log | diff | annotate |
src/sys/sys/event.h | log | diff | annotate | |
message |
kqueue: Revise badfd knote handling When closing a file descriptor and converting the poll/select knotes into badfd knotes, keep the knotes attached to the by-fd table. This should prevent kqueue_purge() from returning before the kqueue has become quiescent. This in turn should fix a KASSERT(TAILQ_EMPTY(&kq->kq_head)) panic in KQRELE() that bluhm@ has reported. The badfd conversion is only needed when a poll/select scan is ongoing. The system can skip the conversion if the knote is not part of the active event set. The code of this commit skips the conversion when the fd is closed by the same thread that has done the fd polling. This can be improved but should already cover typical fd usage patterns. As badfd knotes now hold slots in the by-fd table, kqueue_register() clears them. poll/select use kqueue_register() to set up a new scan; any found fd close notification is a leftover from the previous scan. The new badfd handling should be free of accidental knote accumulation. This obsoletes kqpoll_dequeue() and lowers kqpoll_init() overhead. Re-enable lazy removal of poll/select knotes because the panic should no longer happen. OK mpi@ |