]> granicus.if.org Git - python/commit
bpo-37811: FreeBSD, OSX: fix poll(2) usage in sockets module (GH-15202)
authorArtem Khramov <akhramov@pm.me>
Wed, 14 Aug 2019 21:21:48 +0000 (03:21 +0600)
committerVictor Stinner <vstinner@redhat.com>
Wed, 14 Aug 2019 21:21:48 +0000 (23:21 +0200)
commit28146206578ebe1b84b48e6f255738a227058c04
tree9d6e5c90cba99c1ec804d8999e0dd0b7b2e84b48
parentdcfe111eb5602333135b8776996332a8dcf59392
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.
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