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
1b984ffd
Commit
1b984ffd
authored
Sep 15, 2016
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.5 (issue #28174)
parents
d070154f
5587d7c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+13
-12
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+11
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/asyncio/base_events.py
View file @
1b984ffd
...
...
@@ -76,6 +76,17 @@ def _format_pipe(fd):
return
repr
(
fd
)
def
_set_reuseport
(
sock
):
if
not
hasattr
(
socket
,
'SO_REUSEPORT'
):
raise
ValueError
(
'reuse_port not supported by socket module'
)
else
:
try
:
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEPORT
,
1
)
except
OSError
:
raise
ValueError
(
'reuse_port not supported by socket module, '
'SO_REUSEPORT defined but not implemented.'
)
# Linux's sock.type is a bitmask that can include extra info about socket.
_SOCKET_TYPE_MASK
=
0
if
hasattr
(
socket
,
'SOCK_NONBLOCK'
):
...
...
@@ -874,12 +885,7 @@ class BaseEventLoop(events.AbstractEventLoop):
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
if
reuse_port
:
if
not
hasattr
(
socket
,
'SO_REUSEPORT'
):
raise
ValueError
(
'reuse_port not supported by socket module'
)
else
:
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEPORT
,
1
)
_set_reuseport
(
sock
)
if
allow_broadcast
:
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_BROADCAST
,
1
)
...
...
@@ -1002,12 +1008,7 @@ class BaseEventLoop(events.AbstractEventLoop):
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
True
)
if
reuse_port
:
if
not
hasattr
(
socket
,
'SO_REUSEPORT'
):
raise
ValueError
(
'reuse_port not supported by socket module'
)
else
:
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEPORT
,
True
)
_set_reuseport
(
sock
)
# Disable IPv4/IPv6 dual stack support (enabled by
# default on Linux) which makes a single socket
# listen on both address families.
...
...
Lib/test/test_asyncio/test_base_events.py
View file @
1b984ffd
...
...
@@ -1370,6 +1370,17 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
self
.
assertRaises
(
ValueError
,
self
.
loop
.
run_until_complete
,
f
)
@
patch_socket
def
test_create_server_soreuseport_only_defined
(
self
,
m_socket
):
m_socket
.
getaddrinfo
=
socket
.
getaddrinfo
m_socket
.
socket
.
return_value
=
mock
.
Mock
()
m_socket
.
SO_REUSEPORT
=
-
1
f
=
self
.
loop
.
create_server
(
MyProto
,
'0.0.0.0'
,
0
,
reuse_port
=
True
)
self
.
assertRaises
(
ValueError
,
self
.
loop
.
run_until_complete
,
f
)
@
patch_socket
def
test_create_server_cant_bind
(
self
,
m_socket
):
...
...
Misc/NEWS
View file @
1b984ffd
...
...
@@ -421,6 +421,9 @@ Library
-
Issue
#
27906
:
Fix
socket
accept
exhaustion
during
high
TCP
traffic
.
Patch
by
Kevin
Conway
.
-
Issue
#
28174
:
Handle
when
SO_REUSEPORT
isn
't properly supported.
Patch by Seth Michael Larson.
IDLE
----
...
...
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