Skip to content

Commit 649f8de

Browse files
author
taras
committed
Optimize and cleanup _do_read_into_void
1 parent d33c852 commit 649f8de

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

uvloop/sslproto.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,17 +610,17 @@ cdef class SSLProtocol:
610610
If close_notify is received for the first time, call eof_received.
611611
"""
612612
cdef:
613-
bint close_notify = False
613+
bytearray buffer = PyBytes_FromStringAndSize(
614+
NULL, SSL_READ_DEFAULT_SIZE)
615+
Py_ssize_t bytes_read = -1
614616
try:
615-
while True:
616-
if not self._sslobj_read(self._ssl_read_max_size_obj):
617-
close_notify = True
618-
break
617+
while bytes_read != 0:
618+
bytes_read = self._sslobj_read(self._ssl_read_max_size_obj, buffer)
619619
except ssl_SSLAgainErrors as exc:
620620
pass
621621
except ssl_SSLZeroReturnError:
622-
close_notify = True
623-
if close_notify:
622+
bytes_read = 0
623+
if bytes_read == 0:
624624
self._call_eof_received(context)
625625

626626
cdef _do_flush(self, object context=None):

0 commit comments

Comments
 (0)