]> git.tuebingen.mpg.de Git - paraslash.git/commit
fd.c: Prefer poll(2) over select(2) for write_ok().
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 29 Sep 2021 20:07:13 +0000 (22:07 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 25 Aug 2022 13:37:26 +0000 (15:37 +0200)
commitf23a3bd46a21cae3749ff6c3d6459e119d4cee89
treedf1ee4b4e4b92ac432feeef573d45affd82a0831
parentfdd8a22e1df57a8c9254e7d0074301e7dde2c557
fd.c: Prefer poll(2) over select(2) for write_ok().

This is easy to do and avoids the old and well-known shortcomings of
select(2). See

http://0pointer.net/blog/file-descriptor-limits.html

for a short discussion, or the references in the log message of commit
e4a403876d2c of the man-pages repository.

The linux poll manpage says:

On some other UNIX systems, poll() can fail with the error EAGAIN if
the system fails to allocate kernel-internal resources, rather than
ENOMEM as Linux does. POSIX permits this behavior. Portable programs
may wish to check for EAGAIN and loop, just as with EINTR.

We do not follow this approach since failing the call in the out of
memory case seems to be the right thing to do while busy looping
without trying to free memory between the calls is not likely to
help. Also, looping on EAGAIN would be inconsistent since in the
OOM case the code would fail on Linux but loop on those other UNIX
systems. To be consistent, one must check for both EAGAIN and ENOMEM.
fd.c