diff options
author | Guido van Rossum <guido@python.org> | 1996-10-12 14:07:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-10-12 14:07:22 (GMT) |
commit | 084814624df0c63a95d5e7f9eb2c83ca06d4a5bd (patch) | |
tree | c34142bfe846112788a5bb939f54dda2a9d106c9 /Modules | |
parent | 9b0581192d6f3f959e724b9db9f7726d3861e180 (diff) | |
download | cpython-084814624df0c63a95d5e7f9eb2c83ca06d4a5bd.zip cpython-084814624df0c63a95d5e7f9eb2c83ca06d4a5bd.tar.gz cpython-084814624df0c63a95d5e7f9eb2c83ca06d4a5bd.tar.bz2 |
Don't close an already closed socket.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/socketmodule.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index ffe6b44..cb802e8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -610,9 +610,11 @@ BUILD_FUNC_DEF_2(PySocketSock_close,PySocketSockObject *,s, PyObject *,args) { if (!PyArg_NoArgs(args)) return NULL; - Py_BEGIN_ALLOW_THREADS - (void) close(s->sock_fd); - Py_END_ALLOW_THREADS + if (s->sock_fd != -1) { + Py_BEGIN_ALLOW_THREADS + (void) close(s->sock_fd); + Py_END_ALLOW_THREADS + } s->sock_fd = -1; Py_INCREF(Py_None); return Py_None; |