summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_multiprocessing/connection.h2
-rw-r--r--Modules/_multiprocessing/socket_connection.c14
2 files changed, 14 insertions, 2 deletions
diff --git a/Modules/_multiprocessing/connection.h b/Modules/_multiprocessing/connection.h
index 155b61b..458d1d3 100644
--- a/Modules/_multiprocessing/connection.h
+++ b/Modules/_multiprocessing/connection.h
@@ -354,7 +354,7 @@ connection_poll(ConnectionObject *self, PyObject *args)
}
Py_BEGIN_ALLOW_THREADS
- res = conn_poll(self, timeout);
+ res = conn_poll(self, timeout, _save);
Py_END_ALLOW_THREADS
switch (res) {
diff --git a/Modules/_multiprocessing/socket_connection.c b/Modules/_multiprocessing/socket_connection.c
index e5d2d15..ad4005b 100644
--- a/Modules/_multiprocessing/socket_connection.c
+++ b/Modules/_multiprocessing/socket_connection.c
@@ -153,11 +153,23 @@ conn_recv_string(ConnectionObject *conn, char *buffer,
*/
static int
-conn_poll(ConnectionObject *conn, double timeout)
+conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save)
{
int res;
fd_set rfds;
+ /*
+ * Verify the handle, issue 3321. Not required for windows.
+ */
+ #ifndef MS_WINDOWS
+ if (((int)conn->handle) < 0 || ((int)conn->handle) >= FD_SETSIZE) {
+ Py_BLOCK_THREADS
+ PyErr_SetString(PyExc_IOError, "handle out of range in select()");
+ Py_UNBLOCK_THREADS
+ return MP_EXCEPTION_HAS_BEEN_SET;
+ }
+ #endif
+
FD_ZERO(&rfds);
FD_SET((SOCKET)conn->handle, &rfds);