On Fri, Oct 22, 2021 at 02:25:18PM +0100, Martin Pieuchot wrote:
> Last year we added the new EVFILT_EXCEPT filter type to kqueue in
> order to report conditions currently available via POLLPRI/POLLRDBAND
> in poll(2) and select(2).
>
> This new filter has been implemented in tty and socket by re-using the
> existing kqueue's "read" filter. This has a downside which is the filter
> will also trigger if any data is available for reading.
>
> This "feature" makes it impossible to correctly implement poll(2)'s
> "empty" condition mode. If no bit are set in the `events' pollfd
> structure we still need to return POLLHUP. But if the filter triggers
> when there's data to read, it means POLLIN not POLLHUP.
>
> So I'd like to change the existing EVFILT_EXCEPT filters to no longer
> fire if there is something to read. Diff below does that and adds a
> new filter for FIFOs necessary for poll(2) support.
I think it is good to make EVFILT_EXCEPT handling separate from the
normal read case.
This does alter the way how EVFILT_EXCEPT behaves. However, the only
documented aspect is NOTE_OOB with sockets and pseudo-terminals, and
its behaviour looks to remain unchanged.
> +int
> +filt_fifoexceptprocess(struct knote *kn, struct kevent *kev)
> +{
> + struct socket *so = kn->kn_hook;
> + int rv, s;
> +
> + s = solock(so);
> + if (kev != NULL && (kn->kn_flags & EV_ONESHOT))
> + rv = 1;
> + else
> + rv = filt_fifoexcept_common(kn, so);
> + if (rv != 0)
> + knote_submit(kn, kev);
> + sounlock(so, s);
> +
> + return (rv);
> +}
> +
>
extra newline above
OK visa@