@@ -375,6 +375,7 @@ cdef class UVStream(UVBaseTransport):
375
375
# uv_try_write -- less layers of code. The error
376
376
# checking logic is copied from libuv.
377
377
written = system.write(fd, buf, blen)
378
+
378
379
while written == - 1 and (
379
380
errno.errno == errno.EINTR or
380
381
(system.PLATFORM_IS_APPLE and
@@ -464,7 +465,7 @@ cdef class UVStream(UVBaseTransport):
464
465
if not buf_len:
465
466
return
466
467
467
- if (< uv.uv_stream_t* > self ._handle).write_queue_size == 0 :
468
+ if not self ._protocol_paused and (< uv.uv_stream_t* > self ._handle).write_queue_size == 0 :
468
469
# libuv internal write buffers for this stream are empty.
469
470
if buf_len == 1 :
470
471
# If we only have one piece of data to send, let's
@@ -681,14 +682,14 @@ cdef class UVStream(UVBaseTransport):
681
682
self ._conn_lost += 1
682
683
return
683
684
684
- cdef int sent
685
+ cdef ssize_t written
685
686
686
- if (self ._buffer_size == 0 and
687
+ if (not self ._protocol_paused and self ._buffer_size == 0 and
687
688
(< uv.uv_stream_t* > self ._handle).write_queue_size == 0 ):
688
689
689
- sent_ = self ._try_write(buf)
690
+ written_ = self ._try_write(buf)
690
691
691
- if sent_ is None :
692
+ if written_ is None :
692
693
# A `self._fatal_error` was called.
693
694
# It might not raise an exception under some
694
695
# conditions.
@@ -698,25 +699,24 @@ cdef class UVStream(UVBaseTransport):
698
699
699
700
return
700
701
701
- sent = sent_
702
+ written = written_
702
703
703
- if sent == 0 :
704
+ if written == 0 :
704
705
# All data was successfully written.
705
706
# on_write will call "maybe_resume_protocol".
706
- self ._on_write()
707
707
return
708
708
709
- if sent > 0 :
709
+ if written > 0 :
710
710
if UVLOOP_DEBUG:
711
- if sent == len (buf):
711
+ if written == len (buf):
712
712
raise RuntimeError (' _try_write sent all data and '
713
713
' returned non-zero' )
714
714
715
715
if PyBytes_CheckExact(buf):
716
716
# Cast bytes to memoryview to avoid copying
717
717
# data that wasn't sent.
718
718
buf = memoryview(buf)
719
- buf = buf[sent :]
719
+ buf = buf[written_ :]
720
720
721
721
# At this point it's either data was sent partially,
722
722
# or an EAGAIN has happened.
@@ -940,7 +940,6 @@ cdef void __uv_stream_on_write(
940
940
uv.uv_write_t* req,
941
941
int status,
942
942
) noexcept with gil:
943
-
944
943
if UVLOOP_DEBUG:
945
944
if req.data is NULL :
946
945
aio_logger.error(
0 commit comments