Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 15604:15e1eb1019b8 legacy-trunk
Adapted from a patch by Barry Scott, SF patch #102875 and SF bug
#125981: closing sockets was not thread-safe.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 18 Dec 2000 22:23:44 +0000 |
| parents | 9731bbb52fb4 |
| children | f9a15a583c79 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Mon Dec 18 17:28:05 2000 +0000 +++ b/Modules/socketmodule.c Mon Dec 18 22:23:44 2000 +0000 @@ -904,14 +904,15 @@ 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; }
