Issue #26685: Raise OSError if closing a socket fails

This commit is contained in:
Martin Panter 2016-04-11 00:38:12 +00:00
parent f01e408c16
commit 50ab1a3694
6 changed files with 26 additions and 2 deletions

View file

@ -2576,6 +2576,7 @@ static PyObject *
sock_close(PySocketSockObject *s)
{
SOCKET_T fd;
int res;
fd = s->sock_fd;
if (fd != -1) {
@ -2586,8 +2587,11 @@ sock_close(PySocketSockObject *s)
http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
for more details. */
Py_BEGIN_ALLOW_THREADS
(void) SOCKETCLOSE(fd);
res = SOCKETCLOSE(fd);
Py_END_ALLOW_THREADS
if (res < 0) {
return s->errorhandler();
}
}
Py_INCREF(Py_None);
return Py_None;