mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
setting monitor interests programatically instead of the :rw everywhere (so timeouts work properly)
This commit is contained in:
parent
0dd9d1152c
commit
e8c150dbca
@ -61,7 +61,7 @@ module HTTPX
|
||||
@io = io
|
||||
@options = Options.new(options)
|
||||
@window_size = @options.window_size
|
||||
@read_buffer = "".b
|
||||
@read_buffer = Buffer.new(BUFFER_SIZE)
|
||||
@write_buffer = Buffer.new(BUFFER_SIZE)
|
||||
@pending = []
|
||||
@state = :idle
|
||||
@ -79,6 +79,17 @@ module HTTPX
|
||||
uri.scheme == @io.scheme
|
||||
end
|
||||
|
||||
def interests
|
||||
return :w if @state == :idle
|
||||
readable = !@read_buffer.full?
|
||||
writable = !@write_buffer.empty?
|
||||
if readable
|
||||
writable ? :rw : :r
|
||||
else
|
||||
writable ? :w : :r
|
||||
end
|
||||
end
|
||||
|
||||
def to_io
|
||||
case @state
|
||||
when :idle
|
||||
@ -134,7 +145,7 @@ module HTTPX
|
||||
throw(:close, self) unless siz
|
||||
return if siz.zero?
|
||||
log { "READ: #{siz} bytes..." }
|
||||
parser << @read_buffer
|
||||
parser << @read_buffer.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -21,6 +21,7 @@ module HTTPX
|
||||
if (channel = monitor.value)
|
||||
consume(channel)
|
||||
end
|
||||
monitor.interests = channel.interests
|
||||
end
|
||||
end
|
||||
|
||||
@ -57,7 +58,7 @@ module HTTPX
|
||||
private
|
||||
|
||||
def register_channel(channel)
|
||||
monitor = @selector.register(channel, :rw)
|
||||
monitor = @selector.register(channel, :w)
|
||||
monitor.value = channel
|
||||
@channels << channel
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user