Skip to content

Commit 854aa0f

Browse files
author
taras
committed
Optimize SSLObject.read call
1 parent 837ef22 commit 854aa0f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

uvloop/sslproto.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ cdef class SSLProtocol:
5757
object _incoming_write
5858
object _outgoing
5959
object _outgoing_read
60+
object _ssl_read_max_size_obj
6061
char* _ssl_buffer
6162
size_t _ssl_buffer_len
6263
object _ssl_buffer_view

uvloop/sslproto.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ cdef class SSLProtocol:
200200
"""
201201

202202
def __cinit__(self, *args, **kwargs):
203+
self._ssl_read_max_size_obj = SSL_READ_MAX_SIZE
203204
self._ssl_buffer_len = SSL_READ_MAX_SIZE
204205
self._ssl_buffer = <char*>PyMem_RawMalloc(self._ssl_buffer_len)
205206
if not self._ssl_buffer:
@@ -587,7 +588,7 @@ cdef class SSLProtocol:
587588
bint close_notify = False
588589
try:
589590
while True:
590-
if not self._sslobj_read(SSL_READ_MAX_SIZE):
591+
if not self._sslobj_read(self._ssl_read_max_size_obj):
591592
close_notify = True
592593
break
593594
except ssl_SSLAgainErrors as exc:
@@ -773,7 +774,7 @@ cdef class SSLProtocol:
773774

774775
try:
775776
while True:
776-
chunk = self._sslobj_read(SSL_READ_MAX_SIZE)
777+
chunk = self._sslobj_read(self._ssl_read_max_size_obj)
777778
if not chunk:
778779
break
779780
if zero:

0 commit comments

Comments
 (0)