about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-19 10:09:55 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-19 17:04:25 -0700
commitcc18035c5105751a3e67a8e449ee0021fd313ea9 (patch)
tree6da4f063accc4bcffee9bed88e8eb0d10a7477d6 /lib
parentb3278b45bd5e31d97ce7b8625585692091ff4755 (diff)
downloadrainbows-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.
Diffstat (limited to 'lib')
-rw-r--r--lib/rainbows/event_machine.rb24
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