Don't close an already closed socket.

This commit is contained in:
Guido van Rossum 1996-10-12 14:07:22 +00:00
parent 9b0581192d
commit 084814624d

View file

@ -610,9 +610,11 @@ BUILD_FUNC_DEF_2(PySocketSock_close,PySocketSockObject *,s, PyObject *,args)
{ {
if (!PyArg_NoArgs(args)) if (!PyArg_NoArgs(args))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS if (s->sock_fd != -1) {
(void) close(s->sock_fd); Py_BEGIN_ALLOW_THREADS
Py_END_ALLOW_THREADS (void) close(s->sock_fd);
Py_END_ALLOW_THREADS
}
s->sock_fd = -1; s->sock_fd = -1;
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;