From ca8ed32c8cc990c7e64b6bd7168808a83405a5a5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 Aug 2010 18:52:48 +0000 Subject: make log reopens even more robust in threaded apps A follow-up to 4b23693b9082a84433a9e6c1f358b58420176b27 If multithreaded programming can be compared to juggling chainsaws, then multithreaded programming with signal handlers in play is akin to juggling chainsaws on a tightrope over shark-infested waters. (cherry picked from commit feab35fe531843066db3418598874cf9f9419614) --- lib/unicorn/util.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/unicorn/util.rb b/lib/unicorn/util.rb index a735c68..e9dd57f 100644 --- a/lib/unicorn/util.rb +++ b/lib/unicorn/util.rb @@ -62,18 +62,18 @@ module Unicorn begin File.open(fp.path, 'a') { |tmpfp| fp.reopen(tmpfp) } - rescue IOError, Errno::EBADF - next - end - fp.sync = true - new_st = fp.stat + fp.sync = true + new_st = fp.stat - # this should only happen in the master: - if orig_st.uid != new_st.uid || orig_st.gid != new_st.gid - fp.chown(orig_st.uid, orig_st.gid) - end + # this should only happen in the master: + if orig_st.uid != new_st.uid || orig_st.gid != new_st.gid + fp.chown(orig_st.uid, orig_st.gid) + end - nr += 1 + nr += 1 + rescue IOError, Errno::EBADF + # not much we can do... + end end nr -- cgit v1.2.3-24-ge0c7