Kaydet (Commit) 20d3fc07 authored tarafından Guido van Rossum's avatar Guido van Rossum

Adapted from a patch by Barry Scott, SF patch #102875 and SF bug

#125981: closing sockets was not thread-safe.
üst 99664e45
...@@ -904,14 +904,15 @@ pair (host, port); the host must refer to the local host."; ...@@ -904,14 +904,15 @@ pair (host, port); the host must refer to the local host.";
static PyObject * static PyObject *
PySocketSock_close(PySocketSockObject *s, PyObject *args) PySocketSock_close(PySocketSockObject *s, PyObject *args)
{ {
SOCKET_T fd;
if (!PyArg_ParseTuple(args, ":close")) if (!PyArg_ParseTuple(args, ":close"))
return NULL; return NULL;
if (s->sock_fd != -1) { if ((fd = s->sock_fd) != -1) {
s->sock_fd = -1;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
(void) SOCKETCLOSE(s->sock_fd); (void) SOCKETCLOSE(fd);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
} }
s->sock_fd = -1;
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment