Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions lib/async/io/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def initialize(io, block_size: BLOCK_SIZE, maximum_read_size: MAXIMUM_READ_SIZE,
@read_buffer = Buffer.new
@write_buffer = Buffer.new
@drain_buffer = Buffer.new

# Used as destination buffer for underlying reads.
@input_buffer = Buffer.new
end

attr :io
Expand Down Expand Up @@ -244,18 +241,13 @@ def fill_read_buffer(size = @block_size)
# This effectively ties the input and output stream together.
flush

if @read_buffer.empty?
if @io.read_nonblock(size, @read_buffer, exception: false)
# Console.logger.debug(self, name: "read") {@read_buffer.inspect}
return true
end
else
if chunk = @io.read_nonblock(size, @input_buffer, exception: false)
@read_buffer << chunk
# Console.logger.debug(self, name: "read") {@read_buffer.inspect}
input_buffer = Buffer.new

if chunk = @io.read_nonblock(size, input_buffer, exception: false)
@read_buffer << chunk
# Console.logger.debug(self, name: "read") {@read_buffer.inspect}

return true
end
return true
end

# else for both cases above:
Expand Down