BUG/MINOR: fd: my_closefrom() on Linux could skip contiguous series of sockets

We got a detailed report analysis showing that our optimization consisting
in using poll() to detect already closed FDs within a 1024 range has an
issue with the case where 1024 consecutive FDs are open (hence do not show
POLLNVAL) and none of them has any activity report. In this case poll()
returns zero update and we would just skip the loop that inspects all the
FDs to close the valid ones. One visible effect is that the called programs
might occasionally see some FDs being exposed in the low range of their fd
space, possibly making the process run out of FDs when trying to open a
file for example.

Note that this is actually a fix for commit b8e602cb1b ("BUG/MINOR: fd:
make sure my_closefrom() doesn't miss some FDs") that already faced a
more common form of this problem (incomplete but non-empty FDs reported).

This can be backported up to 2.0.

(cherry picked from commit 64d20fc9e0a914ad2fe03d74972b56baaf54b90f)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit 0f7e2262a70529c3ec9dc61a55742ea3b261ed1c)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit cfbda6972926462a7915182ff47ae0c2dbfc4506)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit c19c1c973cb5a8c18ab7212ff293eae9d356ef44)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
1 file changed