On Fri, Dec 18, 2020 at 09:16:14AM -0700, Visa Hankala wrote:
> CVSROOT:      /cvs
> Module name:  src
> Changes by:   [email protected]    2020/12/18 09:16:14
> 
> Modified files:
>       sys/kern       : kern_event.c 
>       sys/sys        : eventvar.h 
> 
> Log message:
> Add fd close notification for kqueue-based poll() and select()
> 
> When the file descriptor of an __EV_POLL-flagged knote is closed,
> post EBADF through the kqueue instance to the caller of kqueue_scan().
> This lets kqueue-based poll() and select() preserve their current
> behaviour of returning EBADF when a polled file descriptor is closed
> concurrently.

This comment is wrong with poll(2). poll(2) returns fd-specific errors
through struct pollfd. If the file descriptor is closed, the current code
will return POLLNVAL in the revents bitmask.

The error-through-kqueue_scan() approach lacks detail. As such, it might
not be good enough for poll(2) emulation, unless it is feasible to redo
the scan setup phase, or otherwise recheck the file descriptors, after
getting EBADF from kqueue_scan(). However, such rechecking might not
notice if the file descriptor gets reused quickly.

Reply via email to