Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5587d7c0
Kaydet (Commit)
5587d7c0
authored
Eyl 15, 2016
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28174: Handle when SO_REUSEPORT isn't properly supported (asyncio)
Patch by Seth Michael Larson.
üst
a1b0e7db
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
12 deletions
+27
-12
base_events.py
Lib/asyncio/base_events.py
+13
-12
test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+11
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/asyncio/base_events.py
Dosyayı görüntüle @
5587d7c0
...
@@ -76,6 +76,17 @@ def _format_pipe(fd):
...
@@ -76,6 +76,17 @@ def _format_pipe(fd):
return
repr
(
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.
# Linux's sock.type is a bitmask that can include extra info about socket.
_SOCKET_TYPE_MASK
=
0
_SOCKET_TYPE_MASK
=
0
if
hasattr
(
socket
,
'SOCK_NONBLOCK'
):
if
hasattr
(
socket
,
'SOCK_NONBLOCK'
):
...
@@ -873,12 +884,7 @@ class BaseEventLoop(events.AbstractEventLoop):
...
@@ -873,12 +884,7 @@ class BaseEventLoop(events.AbstractEventLoop):
sock
.
setsockopt
(
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
if
reuse_port
:
if
reuse_port
:
if
not
hasattr
(
socket
,
'SO_REUSEPORT'
):
_set_reuseport
(
sock
)
raise
ValueError
(
'reuse_port not supported by socket module'
)
else
:
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEPORT
,
1
)
if
allow_broadcast
:
if
allow_broadcast
:
sock
.
setsockopt
(
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_BROADCAST
,
1
)
socket
.
SOL_SOCKET
,
socket
.
SO_BROADCAST
,
1
)
...
@@ -1001,12 +1007,7 @@ class BaseEventLoop(events.AbstractEventLoop):
...
@@ -1001,12 +1007,7 @@ class BaseEventLoop(events.AbstractEventLoop):
sock
.
setsockopt
(
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
True
)
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
True
)
if
reuse_port
:
if
reuse_port
:
if
not
hasattr
(
socket
,
'SO_REUSEPORT'
):
_set_reuseport
(
sock
)
raise
ValueError
(
'reuse_port not supported by socket module'
)
else
:
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEPORT
,
True
)
# Disable IPv4/IPv6 dual stack support (enabled by
# Disable IPv4/IPv6 dual stack support (enabled by
# default on Linux) which makes a single socket
# default on Linux) which makes a single socket
# listen on both address families.
# listen on both address families.
...
...
Lib/test/test_asyncio/test_base_events.py
Dosyayı görüntüle @
5587d7c0
...
@@ -1370,6 +1370,17 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
...
@@ -1370,6 +1370,17 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
self
.
assertRaises
(
ValueError
,
self
.
loop
.
run_until_complete
,
f
)
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
@patch_socket
def
test_create_server_cant_bind
(
self
,
m_socket
):
def
test_create_server_cant_bind
(
self
,
m_socket
):
...
...
Misc/NEWS
Dosyayı görüntüle @
5587d7c0
...
@@ -266,6 +266,9 @@ Library
...
@@ -266,6 +266,9 @@ Library
- Issue #27906: Fix socket accept exhaustion during high TCP traffic.
- Issue #27906: Fix socket accept exhaustion during high TCP traffic.
Patch by Kevin Conway.
Patch by Kevin Conway.
- Issue #28174: Handle when SO_REUSEPORT isn'
t
properly
supported
.
Patch
by
Seth
Michael
Larson
.
IDLE
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