mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-10 00:02:10 -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
|
@io = io
|
||||||
@options = Options.new(options)
|
@options = Options.new(options)
|
||||||
@window_size = @options.window_size
|
@window_size = @options.window_size
|
||||||
@read_buffer = "".b
|
@read_buffer = Buffer.new(BUFFER_SIZE)
|
||||||
@write_buffer = Buffer.new(BUFFER_SIZE)
|
@write_buffer = Buffer.new(BUFFER_SIZE)
|
||||||
@pending = []
|
@pending = []
|
||||||
@state = :idle
|
@state = :idle
|
||||||
@ -79,6 +79,17 @@ module HTTPX
|
|||||||
uri.scheme == @io.scheme
|
uri.scheme == @io.scheme
|
||||||
end
|
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
|
def to_io
|
||||||
case @state
|
case @state
|
||||||
when :idle
|
when :idle
|
||||||
@ -134,7 +145,7 @@ module HTTPX
|
|||||||
throw(:close, self) unless siz
|
throw(:close, self) unless siz
|
||||||
return if siz.zero?
|
return if siz.zero?
|
||||||
log { "READ: #{siz} bytes..." }
|
log { "READ: #{siz} bytes..." }
|
||||||
parser << @read_buffer
|
parser << @read_buffer.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ module HTTPX
|
|||||||
if (channel = monitor.value)
|
if (channel = monitor.value)
|
||||||
consume(channel)
|
consume(channel)
|
||||||
end
|
end
|
||||||
|
monitor.interests = channel.interests
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ module HTTPX
|
|||||||
private
|
private
|
||||||
|
|
||||||
def register_channel(channel)
|
def register_channel(channel)
|
||||||
monitor = @selector.register(channel, :rw)
|
monitor = @selector.register(channel, :w)
|
||||||
monitor.value = channel
|
monitor.value = channel
|
||||||
@channels << channel
|
@channels << channel
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user