diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-19 10:09:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-19 17:04:25 -0700 |
commit | cc18035c5105751a3e67a8e449ee0021fd313ea9 (patch) | |
tree | 6da4f063accc4bcffee9bed88e8eb0d10a7477d6 | |
parent | b3278b45bd5e31d97ce7b8625585692091ff4755 (diff) | |
download | rainbows-cc18035c5105751a3e67a8e449ee0021fd313ea9.tar.gz |
No need to double up on begin blocks since we know @client.write won't raise exceptions @io.read_nonblock does. Also prefer @client.write to @client.send_data since it looks more in line with other IO interfaces.
-rw-r--r-- | lib/rainbows/event_machine.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index 3837e1f..625357e 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -195,19 +195,17 @@ module Rainbows def notify_readable begin - data = begin - @io.read_nonblock(16384, BUF) - rescue Errno::EINTR - retry - rescue Errno::EAGAIN - return - rescue EOFError - detach - return - end - @client.send_data(sprintf("%x\r\n", data.size)) - @client.send_data(data) - @client.send_data("\r\n") + data = @io.read_nonblock(16384, BUF) + @client.write(sprintf("%x\r\n", data.size)) + @client.write(data) + @client.write("\r\n") + rescue Errno::EINTR + retry + rescue Errno::EAGAIN + return + rescue EOFError + detach + return end while true end end |