Skip to content

Commit 25e830d

Browse files
committed
Tighten up code in loop.connect_accepted_socket
1 parent 59026e3 commit 25e830d

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

uvloop/loop.pyx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,31 +1930,23 @@ cdef class Loop:
19301930
raise ValueError('invalid socket type, SOCK_STREAM expected')
19311931

19321932
fileno = sock.fileno()
1933-
protocol = protocol_factory()
1933+
app_protocol = protocol_factory()
19341934
waiter = self._new_future()
19351935

19361936
if ssl is None:
1937-
if sock.family == uv.AF_UNIX:
1938-
transport = <UVStream>UnixTransport.new(
1939-
self, protocol, None, waiter)
1940-
1941-
elif sock.family in (uv.AF_INET, uv.AF_INET6):
1942-
transport = <UVStream>TCPTransport.new(
1943-
self, protocol, None, waiter)
1944-
1937+
protocol = app_protocol
19451938
else:
1946-
ssl_protocol = aio_SSLProtocol(
1947-
self, protocol, ssl, waiter,
1939+
protocol = aio_SSLProtocol(
1940+
self, app_protocol, ssl, waiter,
19481941
True, # server_side
19491942
None) # server_hostname
19501943

1951-
if sock.family == uv.AF_UNIX:
1952-
transport = <UVStream>UnixTransport.new(
1953-
self, ssl_protocol, None, None)
1954-
1955-
elif sock.family in (uv.AF_INET, uv.AF_INET6):
1956-
transport = <UVStream>TCPTransport.new(
1957-
self, ssl_protocol, None, None)
1944+
if sock.family == uv.AF_UNIX:
1945+
transport = <UVStream>UnixTransport.new(
1946+
self, protocol, None, waiter)
1947+
elif sock.family in (uv.AF_INET, uv.AF_INET6):
1948+
transport = <UVStream>TCPTransport.new(
1949+
self, protocol, None, waiter)
19581950

19591951
if transport is None:
19601952
raise ValueError(

0 commit comments

Comments
 (0)