about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-31 00:37:49 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-31 00:37:49 -0700
commit7dd3d804e9199a201aa62b7f7e7c28ddeace99c5 (patch)
tree2795914d27c5ceac291f9b8dd588b6fd644022ae /lib
parent6ab8a56ed27320746cf6d95a1b3e9fe4ddb99d75 (diff)
downloadunicorn-7dd3d804e9199a201aa62b7f7e7c28ddeace99c5.tar.gz
Instead of trusting sysread/syswrite to throw EAGAIN if the pipe
is full (highly unlikely); just use non-blocking methods which
are indeed non-blocking and don't care for the #blocking= method
added to it.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 7ffc8a5..cbbb283 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -161,7 +161,6 @@ module Unicorn
       # this pipe is used to wake us up from select(2) in #join when signals
       # are trapped.  See trap_deferred
       @rd_sig, @wr_sig = IO.pipe unless (@rd_sig && @wr_sig)
-      @rd_sig.nonblock = @wr_sig.nonblock = true
       mode = nil
       respawn = true
 
@@ -262,16 +261,16 @@ module Unicorn
       begin
         ready = IO.select([@rd_sig], nil, nil, 1)
         ready && ready[0] && ready[0][0] or return
-        loop { @rd_sig.sysread(Const::CHUNK_SIZE) }
+        loop { @rd_sig.read_nonblock(Const::CHUNK_SIZE) }
       rescue Errno::EAGAIN, Errno::EINTR
       end
     end
 
     def awaken_master
       begin
-        @wr_sig.syswrite('.') # wakeup master process from IO.select
-      rescue Errno::EAGAIN # pipe is full, master should wake up anyways
-      rescue Errno::EINTR
+        @wr_sig.write_nonblock('.') # wakeup master process from IO.select
+      rescue Errno::EAGAIN, Errno::EINTR
+        # pipe is full, master should wake up anyways
         retry
       end
     end