This repository was archived by the owner on Aug 29, 2024. It is now read-only.
This repository was archived by the owner on Aug 29, 2024. It is now read-only.
Async::IO::Stream#write
doesn't flush to IO even when sync
is true
#79Open
Description
What the title says.
# Writes `string` to the buffer. When the buffer is full or #sync is true the
# buffer is flushed to the underlying `io`.
# @param string the string to write to the buffer.
# @return the number of bytes appended to the buffer.
def write(string)
@write_buffer << string
if @write_buffer.bytesize >= @block_size
flush
end
return string.bytesize
end
In contrast to the documentation, the method only flushes when the write_buffer
is full. This is what's causing the tests to hang in my PR to protocol-http2.
Specifically here in test/protocol/http2/client.rb
it sends the connection preface, but that is too small to fill up the write buffer so it never gets flushed. Hence the following framer.read_connection_preface
indefinitely hangs.
Changing the Async::IO::Stream#write
to
# Writes `string` to the buffer. When the buffer is full or #sync is true the
# buffer is flushed to the underlying `io`.
# @param string the string to write to the buffer.
# @return the number of bytes appended to the buffer.
def write(string)
@write_buffer << string
if @io.sync || @write_buffer.bytesize >= @block_size
# ^^^^^^^^^^^ <-- the change
flush
end
return string.bytesize
end
fixes it, and the test suite works. Is the unconditional buffering intended?
Metadata
Metadata
Assignees
Labels
No labels