Hello, while investigating the cause of the infinite hang in WGET2-MINGW, I
discovered that the gnulib implementation of the poll() function does not
set the POLLIN event flag in revents (but only the POLLHUP flag) after the
connection is hang up (see https://gitlab.com/gnuwget/wget2/-/issues/715).

The reasons why poll() should also set the POLLIN event flag in revents
(not only the POLLHUP flag) in this situation are as follows:

(1) The semantics of POLLIN mean that reading the socket can be done
without blocking (not that there is data in the socket buffer).

(2) There are already established patterns of using this function, when the
application first waits for the POLLIN event, and then, based on the result
of the read operation, determines whether the connection was closed
correctly or whether the connection was broken.

(3) The Linux native poll() implementation sets the POLLIN event flag
(along with the POLLHUP flag) in revents under the same circumstances .

In the attached patch, I propose a fix for the poll() function.

Best regards,
Sergei Litvin

Attachment: 0001-Fix-poll-does-not-set-POLLIN-event-flag-in-revents.patch
Description: Binary data

Reply via email to