Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d9dbf493
Commit
d9dbf493
authored
Oct 24, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accepted sockets shouldn't inherit the SOCK_NONBLOCK flag (closes #25471)
parent
458123bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/socket.py
Lib/socket.py
+5
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/socket.py
View file @
d9dbf493
...
...
@@ -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.
...
...
Lib/test/test_socket.py
View file @
d9dbf493
...
...
@@ -3863,6 +3863,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
read
,
write
,
err
=
select
.
select
([
self
.
serv
],
[],
[])
if
self
.
serv
in
read
:
conn
,
addr
=
self
.
serv
.
accept
()
self
.
assertIsNone
(
conn
.
gettimeout
())
conn
.
close
()
else
:
self
.
fail
(
"Error trying to do accept after select."
)
...
...
Misc/NEWS
View file @
d9dbf493
...
...
@@ -96,6 +96,9 @@ Core and Builtins
Library
-------
- Issue #25471: Sockets returned from accept() shouldn'
t
appear
to
be
nonblocking
.
-
Issue
#
25441
:
asyncio
:
Raise
error
from
drain
()
when
socket
is
closed
.
-
Issue
#
25411
:
Improved
Unicode
support
in
SMTPHandler
through
better
use
of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment