diff options
author | Riccardo Coccioli <volans-@users.noreply.github.com> | 2017-10-18 14:04:04 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-10-18 15:04:04 +0300 |
commit | 27b951c63353345cdf7a9a8c4c8133a5dafd6a80 (patch) | |
tree | 6adac0c5a137c1ce62c9e989a06fd5e3a0b67288 /Modules/selectmodule.c | |
parent | ed267e3305a54eddae8106bdaae2c62d4c3b7db6 (diff) | |
download | cpython-git-27b951c63353345cdf7a9a8c4c8133a5dafd6a80.tar.gz |
[2.7] bpo-31334: Fix timeout in select.poll.poll() (GH-3277) (#4034)
Always pass -1, or INFTIM where defined, to the poll() system call when
a negative timeout is passed to the poll.poll([timeout]) method in the
select module. Various OSes throw an error with arbitrary negative
values..
(cherry picked from commit 6cfa927ceb931ad968b5b03e4a2bffb64a8a0604)
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r-- | Modules/selectmodule.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index a38aa08798..ce4c15b694 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -530,6 +530,17 @@ poll_poll(pollObject *self, PyObject *args) return NULL; } + /* On some OSes, typically BSD-based ones, the timeout parameter of the + poll() syscall, when negative, must be exactly INFTIM, where defined, + or -1. See issue 31334. */ + if (timeout < 0) { +#ifdef INFTIM + timeout = INFTIM; +#else + timeout = -1; +#endif + } + /* Avoid concurrent poll() invocation, issue 8865 */ if (self->poll_running) { PyErr_SetString(PyExc_RuntimeError, |