diff options
author | Guido van Rossum <guido@python.org> | 2000-12-18 22:23:44 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-12-18 22:23:44 (GMT) |
commit | 20d3fc071bb16bb63333de4bb4d66fd0e7f68b64 (patch) | |
tree | ebad73be4ff4e966b14e1206cfdcba2960180ea6 /Modules | |
parent | 99664e455ba9e02e74563e369d7f70bc2faea3e0 (diff) | |
download | cpython-20d3fc071bb16bb63333de4bb4d66fd0e7f68b64.zip cpython-20d3fc071bb16bb63333de4bb4d66fd0e7f68b64.tar.gz cpython-20d3fc071bb16bb63333de4bb4d66fd0e7f68b64.tar.bz2 |
Adapted from a patch by Barry Scott, SF patch #102875 and SF bug
#125981: closing sockets was not thread-safe.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/socketmodule.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index e9b3aad..11e87bc 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -904,14 +904,15 @@ pair (host, port); the host must refer to the local host."; static PyObject * PySocketSock_close(PySocketSockObject *s, PyObject *args) { + SOCKET_T fd; if (!PyArg_ParseTuple(args, ":close")) return NULL; - if (s->sock_fd != -1) { + if ((fd = s->sock_fd) != -1) { + s->sock_fd = -1; Py_BEGIN_ALLOW_THREADS - (void) SOCKETCLOSE(s->sock_fd); + (void) SOCKETCLOSE(fd); Py_END_ALLOW_THREADS } - s->sock_fd = -1; Py_INCREF(Py_None); return Py_None; } |