diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-10-25 03:06:04 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-10-25 03:06:04 (GMT) |
commit | d9dbf493837b798757ed68dbd97dd55cd0c6efa5 (patch) | |
tree | ab712037d2f289ce073d32c7b35c6a023a2034c3 /Lib/socket.py | |
parent | 458123bd18e663919f441a69e01e8c76d5b01a98 (diff) | |
download | cpython-d9dbf493837b798757ed68dbd97dd55cd0c6efa5.zip cpython-d9dbf493837b798757ed68dbd97dd55cd0c6efa5.tar.gz cpython-d9dbf493837b798757ed68dbd97dd55cd0c6efa5.tar.bz2 |
accepted sockets shouldn't inherit the SOCK_NONBLOCK flag (closes #25471)
Diffstat (limited to 'Lib/socket.py')
-rw-r--r-- | Lib/socket.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index 0045886..ff2f087 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -185,7 +185,11 @@ class socket(_socket.socket): For IP sockets, the address info is a pair (hostaddr, port). """ fd, addr = self._accept() - sock = socket(self.family, self.type, self.proto, fileno=fd) + # If our type has the SOCK_NONBLOCK flag, we shouldn't pass it onto the + # new socket. We do not currently allow passing SOCK_NONBLOCK to + # accept4, so the returned socket is always blocking. + type = self.type & ~globals().get("SOCK_NONBLOCK", 0) + sock = socket(self.family, type, self.proto, fileno=fd) # Issue #7995: if no default timeout is set and the listening # socket had a (non-zero) timeout, force the new socket in blocking # mode to override platform-specific socket flags inheritance. |