From 49acd52b3f67d5be433babc38a28ea6865af38a5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 29 Oct 2009 22:47:37 -0700 Subject: cleanup: avoid redundant error checks for fstat If fstat() fails on an open file descriptor in the master, something is seriously wrong (like your kernel is broken/buggy) and trying to restart the worker that owned that file descriptor is likely masking the symptoms. Instead let the error propagate up to the main loop to avoid wasting cycles to restart broken workers. --- lib/unicorn.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 7081164..ae1de59 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -471,16 +471,8 @@ module Unicorn # is stale for >timeout seconds, then we'll kill the corresponding # worker. def murder_lazy_workers - diff = stat = nil WORKERS.dup.each_pair do |wpid, worker| - stat = begin - worker.tmp.stat - rescue => e - logger.warn "worker=#{worker.nr} PID:#{wpid} stat error: #{e.inspect}" - kill_worker(:QUIT, wpid) - next - end - (diff = (Time.now - stat.ctime)) <= timeout and next + (diff = (Time.now - worker.tmp.stat.ctime)) <= timeout and next logger.error "worker=#{worker.nr} PID:#{wpid} timeout " \ "(#{diff}s > #{timeout}s), killing" kill_worker(:KILL, wpid) # take no prisoners for timeout violations -- cgit v1.2.3-24-ge0c7