The listen version of EVFILT_READ for sockets differs somewhat from the code in soo_poll(). The following patch adds a poll/select branch to make the listen filter more consistent with the old code.
OK? Index: kern/uipc_socket.c =================================================================== RCS file: src/sys/kern/uipc_socket.c,v retrieving revision 1.270 diff -u -p -r1.270 uipc_socket.c --- kern/uipc_socket.c 13 Dec 2021 14:56:55 -0000 1.270 +++ kern/uipc_socket.c 23 Dec 2021 14:20:54 -0000 @@ -2318,11 +2318,23 @@ filt_soexceptprocess(struct knote *kn, s int filt_solisten_common(struct knote *kn, struct socket *so) { + int active; + soassertlocked(so); kn->kn_data = so->so_qlen; + active = (kn->kn_data != 0); + + if (kn->kn_flags & (__EV_POLL | __EV_SELECT)) { + if (so->so_state & SS_ISDISCONNECTED) { + kn->kn_flags |= __EV_HUP; + active = 1; + } else { + active = soreadable(so); + } + } - return (kn->kn_data != 0); + return (active); } int