[Python-checkins] cpython: Issue #23618: Fix EINTR handling in socket.connect()
victor.stinner
python-checkins at python.org
Tue Mar 31 21:37:42 CEST 2015
https://hg.python.org/cpython/rev/4fad2b9fc4e6
changeset: 95335:4fad2b9fc4e6
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Mar 31 21:28:42 2015 +0200
summary:
Issue #23618: Fix EINTR handling in socket.connect()
Call PyErr_CheckSignals() if connect(), select() or getsockopt() failed with
EINTR.
files:
Modules/socketmodule.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2502,6 +2502,9 @@
}
*timeoutp = timeout;
+ if (err == EINTR && PyErr_CheckSignals())
+ return -1;
+
assert(err >= 0);
return err;
@@ -2524,13 +2527,14 @@
return NULL;
res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout);
+ if (res < 0)
+ return NULL;
if (timeout == 1) {
PyErr_SetString(socket_timeout, "timed out");
return NULL;
}
- if (res < 0)
- return NULL;
+
if (res != 0) {
#ifdef MS_WINDOWS
WSASetLastError(res);
@@ -2539,8 +2543,8 @@
#endif
return s->errorhandler();
}
- Py_INCREF(Py_None);
- return Py_None;
+
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(connect_doc,
@@ -2564,15 +2568,9 @@
return NULL;
res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout);
-
if (res < 0)
return NULL;
- /* Signals are not errors (though they may raise exceptions). Adapted
- from PyErr_SetFromErrnoWithFilenameObject(). */
- if (res == EINTR && PyErr_CheckSignals())
- return NULL;
-
return PyLong_FromLong((long) res);
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list