From 04ec4d56470bff2c6ae788945785c75f314433c4 Mon Sep 17 00:00:00 2001 From: taras Date: Tue, 10 Sep 2024 00:54:52 +0200 Subject: [PATCH] Call UVStream.write directly from SSLProtocol --- uvloop/handles/stream.pxd | 2 ++ uvloop/handles/stream.pyx | 2 +- uvloop/sslproto.pyx | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/uvloop/handles/stream.pxd b/uvloop/handles/stream.pxd index 8ca87437..df2e3615 100644 --- a/uvloop/handles/stream.pxd +++ b/uvloop/handles/stream.pxd @@ -16,6 +16,8 @@ cdef class UVStream(UVBaseTransport): Py_buffer _read_pybuf bint _read_pybuf_acquired + cpdef write(self, object buf) + # All "inline" methods are final cdef inline _init(self, Loop loop, object protocol, Server server, diff --git a/uvloop/handles/stream.pyx b/uvloop/handles/stream.pyx index b60b264c..30f83979 100644 --- a/uvloop/handles/stream.pyx +++ b/uvloop/handles/stream.pyx @@ -676,7 +676,7 @@ cdef class UVStream(UVBaseTransport): self.__reading, id(self)) - def write(self, object buf): + cpdef write(self, object buf): self._ensure_alive() if self._eof: diff --git a/uvloop/sslproto.pyx b/uvloop/sslproto.pyx index 9015ba57..5442b5d0 100644 --- a/uvloop/sslproto.pyx +++ b/uvloop/sslproto.pyx @@ -705,7 +705,10 @@ cdef class SSLProtocol: if not self._ssl_writing_paused: data = self._outgoing_read() if len(data): - self._transport.write(data) + if isinstance(self._transport, UVStream): + (self._transport).write(data) + else: + self._transport.write(data) # Incoming flow