[Python-checkins] bpo-35310: Clear select() lists before returning upon EINTR (GH-10877)
Miss Islington (bot)
webhook-mailer at python.org
Wed Dec 5 16:29:11 EST 2018
https://github.com/python/cpython/commit/b2e0649dd9a36d54478d0edb623a18d7379e6f19
commit: b2e0649dd9a36d54478d0edb623a18d7379e6f19
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018年12月05日T13:29:08-08:00
summary:
bpo-35310: Clear select() lists before returning upon EINTR (GH-10877)
select() calls are retried on EINTR (per PEP 475). However, if a
timeout was provided and the deadline has passed after running the
signal handlers, rlist, wlist and xlist should be cleared since select(2)
left them unmodified.
(cherry picked from commit 7f52415a6d4841d77d3b7853e83b25a22e0048dc)
Co-authored-by: Oran Avraham <252748+oranav at users.noreply.github.com>
files:
A Misc/NEWS.d/next/Library/2018-12-03-19-45-00.bpo-35310.9k28gR.rst
M Modules/selectmodule.c
diff --git a/Misc/NEWS.d/next/Library/2018-12-03-19-45-00.bpo-35310.9k28gR.rst b/Misc/NEWS.d/next/Library/2018-12-03-19-45-00.bpo-35310.9k28gR.rst
new file mode 100644
index 000000000000..1ab2e168c86a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-12-03-19-45-00.bpo-35310.9k28gR.rst
@@ -0,0 +1,4 @@
+Fix a bug in :func:`select.select` where, in some cases, the file descriptor
+sequences were returned unmodified after a signal interruption, even though the
+file descriptors might not be ready yet. :func:`select.select` will now always
+return empty lists if a timeout has occurred. Patch by Oran Avraham.
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index f02f5ae4e10c..4b9965724915 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -279,6 +279,10 @@ select_select(PyObject *self, PyObject *args)
if (tvp) {
timeout = deadline - _PyTime_GetMonotonicClock();
if (timeout < 0) {
+ /* bpo-35310: lists were unmodified -- clear them explicitly */
+ FD_ZERO(&ifdset);
+ FD_ZERO(&ofdset);
+ FD_ZERO(&efdset);
n = 0;
break;
}
More information about the Python-checkins
mailing list