From 364d2669e9f718813b0883b0d9f2428303af1dcd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 8 Jun 2010 05:11:16 +0000 Subject: cleanup master_sleep loop No need for extra checks when we're just doing read_nonblock. We'll also avoid reallocating a 16K buffer every time we sleep, we can just reuse the buffer the workers normally use to process request. --- lib/unicorn.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index a363014..b34e11a 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -483,11 +483,11 @@ module Unicorn # Wake up every second anyways to run murder_lazy_workers def master_sleep(sec) begin - ready = IO.select([SELF_PIPE.first], nil, nil, sec) or return - ready.first && ready.first.first or return - loop { SELF_PIPE.first.read_nonblock(Const::CHUNK_SIZE) } + IO.select([ SELF_PIPE.first ], nil, nil, sec) or return + SELF_PIPE.first.read_nonblock(Const::CHUNK_SIZE, HttpRequest::BUF) rescue Errno::EAGAIN, Errno::EINTR - end + break + end while true end def awaken_master -- cgit v1.2.3-24-ge0c7