diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-08 05:33:49 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-08 05:36:18 +0000 |
commit | 5ece8c1c33f10e6496dfe5ae1d0d368293278d2d (patch) | |
tree | 2ba247c01f9f3a1de2fce758e85efabc931c6739 /lib/unicorn.rb | |
parent | 1cd698f8c7938b1f19e9ba091708cb4515187939 (diff) | |
download | unicorn-5ece8c1c33f10e6496dfe5ae1d0d368293278d2d.tar.gz |
"[]" is slightly faster under Ruby 1.9 (but slightly slower under 1.8).
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r-- | lib/unicorn.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index a7b0646..e60dd61 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -482,8 +482,8 @@ module Unicorn # Wake up every second anyways to run murder_lazy_workers def master_sleep(sec) begin - IO.select([ SELF_PIPE.first ], nil, nil, sec) or return - SELF_PIPE.first.read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF) + IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return + SELF_PIPE[0].read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF) rescue Errno::EAGAIN, Errno::EINTR break end while true @@ -491,7 +491,7 @@ module Unicorn def awaken_master begin - SELF_PIPE.last.write_nonblock('.') # wakeup master process from select + SELF_PIPE[1].write_nonblock('.') # wakeup master process from select rescue Errno::EAGAIN, Errno::EINTR # pipe is full, master should wake up anyways retry @@ -635,7 +635,7 @@ module Unicorn client.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) response = app.call(env = REQUEST.read(client)) - if 100 == response.first.to_i + if 100 == response[0].to_i client.write(Const::EXPECT_100_RESPONSE) env.delete(Const::HTTP_EXPECT) response = app.call(env) @@ -684,7 +684,7 @@ module Unicorn ready = LISTENERS # closing anything we IO.select on will raise EBADF - trap(:USR1) { nr = -65536; SELF_PIPE.first.close rescue nil } + trap(:USR1) { nr = -65536; SELF_PIPE[0].close rescue nil } trap(:QUIT) { alive = nil; LISTENERS.each { |s| s.close rescue nil } } [:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown logger.info "worker=#{worker.nr} ready" @@ -725,7 +725,7 @@ module Unicorn begin # timeout used so we can detect parent death: ret = IO.select(LISTENERS, nil, SELF_PIPE, timeout) or redo - ready = ret.first + ready = ret[0] rescue Errno::EINTR ready = LISTENERS rescue Errno::EBADF |