Skip to content

Commit 5385ebe

Browse files
author
taras
committed
Cleanup
1 parent 33d0ea4 commit 5385ebe

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

uvloop/sslproto.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ cdef class SSLProtocol:
8181
bint _app_protocol_is_buffer
8282
object _app_protocol_get_buffer
8383
object _app_protocol_buffer_updated
84+
object _app_protocol_data_received
8485

8586
object _handshake_start_time
8687
object _handshake_timeout_handle

uvloop/sslproto.pyx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ cdef class SSLProtocol:
293293
self._ssl_read_buffer = None
294294
else:
295295
self._app_protocol_is_buffer = False
296+
self._app_protocol_data_received = app_protocol.data_received
296297
if self._ssl_read_buffer is None:
297298
self._ssl_read_buffer = PyByteArray_FromStringAndSize(
298299
NULL, SSL_READ_MAX_SIZE)
@@ -361,7 +362,7 @@ cdef class SSLProtocol:
361362
cdef get_buffer_impl(self, size_t n, char** buf, size_t* buf_size):
362363
cdef Py_ssize_t want = min(<Py_ssize_t>n, SSL_READ_MAX_SIZE)
363364

364-
if len(self._plain_read_buffer) < want:
365+
if PyByteArray_GET_SIZE(self._plain_read_buffer) < want:
365366
PyByteArray_Resize(self._plain_read_buffer, want)
366367
if self._ssl_read_buffer is not None:
367368
PyByteArray_Resize(self._ssl_read_buffer, want)
@@ -371,7 +372,7 @@ cdef class SSLProtocol:
371372

372373
cdef buffer_updated_impl(self, size_t nbytes):
373374
mv = PyMemoryView_FromMemory(
374-
self._plain_read_buffer,
375+
PyByteArray_AS_STRING(self._plain_read_buffer),
375376
nbytes,
376377
PyBUF_WRITE
377378
)
@@ -855,10 +856,11 @@ cdef class SSLProtocol:
855856
pass
856857

857858
if data is not None:
858-
self._app_protocol.data_received(b''.join(data))
859+
self._app_protocol_data_received(b''.join(data))
859860
elif first_chunk is not None:
860-
self._app_protocol.data_received(first_chunk)
861-
elif bytes_read == 0:
861+
self._app_protocol_data_received(first_chunk)
862+
863+
if bytes_read == 0:
862864
# close_notify
863865
self._call_eof_received()
864866
self._start_shutdown()

0 commit comments

Comments
 (0)