mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Adapted from a patch by Barry Scott, SF patch #102875 and SF bug
#125981: closing sockets was not thread-safe.
This commit is contained in:
parent
99664e455b
commit
20d3fc071b
1 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue