]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-37811: FreeBSD, OSX: fix poll(2) usage in sockets module (GH-15202)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 14 Aug 2019 21:48:03 +0000 (14:48 -0700)
committerGitHub <noreply@github.com>
Wed, 14 Aug 2019 21:48:03 +0000 (14:48 -0700)
commitb0b178a2b80974da910ce6a344d66cc4d9a2fcfa
tree47e8da05875d686325523d186488c55d11ba2ab6
parent88cce7b59fa503616295ca1a25bce6251f9cd317
bpo-37811: FreeBSD, OSX: fix poll(2) usage in sockets module (GH-15202)

FreeBSD implementation of poll(2) restricts the timeout argument to be
either zero, or positive, or equal to INFTIM (-1).

Unless otherwise overridden, socket timeout defaults to -1. This value
is then converted to milliseconds (-1000) and used as argument to the
poll syscall. poll returns EINVAL (22), and the connection fails.

This bug was discovered during the EINTR handling testing, and the
reproduction code can be found in
https://bugs.python.org/issue23618 (see connect_eintr.py,
attached). On GNU/Linux, the example runs as expected.

This change is trivial:
If the supplied timeout value is negative, truncate it to -1.
(cherry picked from commit 28146206578ebe1b84b48e6f255738a227058c04)

Co-authored-by: Artem Khramov <akhramov@pm.me>
Misc/ACKS
Misc/NEWS.d/next/Library/2019-08-14-21-41-07.bpo-37811.d1xYj7.rst [new file with mode: 0644]
Modules/socketmodule.c