about summary refs log tree commit homepage
path: root/lib/rainbows/epoll
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-24 17:13:14 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-24 17:13:14 -0800
commit9f7f497dc21d904a1af20465318d85811daf0652 (patch)
tree1c0fce07061cdb8c26b8a1083119a82e8f4b9a57 /lib/rainbows/epoll
parent04b8649b3750a0002094e90a62f7566059c8a4e9 (diff)
downloadrainbows-9f7f497dc21d904a1af20465318d85811daf0652.tar.gz
We're living on the EDGE and mixing epoll with threads :D
Diffstat (limited to 'lib/rainbows/epoll')
-rw-r--r--lib/rainbows/epoll/client.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/rainbows/epoll/client.rb b/lib/rainbows/epoll/client.rb
index dfa5652..2e45b26 100644
--- a/lib/rainbows/epoll/client.rb
+++ b/lib/rainbows/epoll/client.rb
@@ -139,7 +139,6 @@ module Rainbows::Epoll::Client
       handle_error(e)
   end
 
-  # this returns an +Array+ write buffer if blocked
   def write(buf)
     unless @wr_queue[0]
       case rv = kgio_trywrite(buf)
@@ -148,11 +147,11 @@ module Rainbows::Epoll::Client
       when String
         buf = rv # retry
       when :wait_writable
-        EP.set(self, OUT)
         break # queue
       end while true
     end
     @wr_queue << buf.dup # >3-word 1.9 strings are copy-on-write
+    EP.set(self, OUT)
   end
 
   def close
@@ -209,7 +208,8 @@ module Rainbows::Epoll::Client
   def stream_pipe(pipe)
     case buf = pipe.tryread
     when String
-      if Array === write(buf)
+      write(buf)
+      if @wr_queue[0]
         # client is blocked on write, client will pull from pipe later
         EP.delete pipe
         @wr_queue << pipe