diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-02-04 20:39:41 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-02-04 20:39:41 -0800 |
commit | 7246d2f2d1601dbb5486ce7f9ddbebd1bb975b58 (patch) | |
tree | fd2c407b4c9bed38fbfc2d586a3c5c905954045a /lib/rainbows/event_machine | |
parent | e00c2e8c53ad5b47baa5bc6a8765b7c3c92296b9 (diff) | |
download | rainbows-7246d2f2d1601dbb5486ce7f9ddbebd1bb975b58.tar.gz |
We want to use the singleton methods in Kgio to reduce conditionals.
Diffstat (limited to 'lib/rainbows/event_machine')
-rw-r--r-- | lib/rainbows/event_machine/response_chunk_pipe.rb | 12 | ||||
-rw-r--r-- | lib/rainbows/event_machine/response_pipe.rb | 13 |
2 files changed, 11 insertions, 14 deletions
diff --git a/lib/rainbows/event_machine/response_chunk_pipe.rb b/lib/rainbows/event_machine/response_chunk_pipe.rb index af9393a..be98086 100644 --- a/lib/rainbows/event_machine/response_chunk_pipe.rb +++ b/lib/rainbows/event_machine/response_chunk_pipe.rb @@ -9,17 +9,15 @@ module Rainbows::EventMachine::ResponseChunkPipe end def notify_readable - begin - data = @io.read_nonblock(16384, RBUF) + case data = Kgio.tryread(@io, 16384, RBUF) + when String @client.write("#{data.size.to_s(16)}\r\n") @client.write(data) @client.write("\r\n") - rescue Errno::EINTR - rescue Errno::EAGAIN - return - rescue EOFError - detach + when :wait_readable return + when nil + return detach end while true end end diff --git a/lib/rainbows/event_machine/response_pipe.rb b/lib/rainbows/event_machine/response_pipe.rb index 0ea1eae..1f7b08a 100644 --- a/lib/rainbows/event_machine/response_pipe.rb +++ b/lib/rainbows/event_machine/response_pipe.rb @@ -10,14 +10,13 @@ module Rainbows::EventMachine::ResponsePipe end def notify_readable - begin - @client.write(@io.read_nonblock(16384, RBUF)) - rescue Errno::EINTR - rescue Errno::EAGAIN - return - rescue EOFError - detach + case data = Kgio.tryread(@io, 16384, RBUF) + when String + @client.write(data) + when :wait_readable return + when nil + return detach end while true end |