diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-08 19:56:29 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-08 20:11:51 -0700 |
commit | 24a1b4c6b5fcb948e4fdee04e286c044d6d45f98 (patch) | |
tree | 1c83dfb542124f0fbaf76e3d1fb83e413c0f6cc1 | |
parent | 94b18a11a5445019d4de010271020dfb190e16e7 (diff) | |
download | unicorn-24a1b4c6b5fcb948e4fdee04e286c044d6d45f98.tar.gz |
This removes the Time.now.to_i comparison that was used to avoid multiple, no-op fchmod() syscalls[1] within the same second. This should allow us to run on OpenBSD where it can raise EINVAL when Time.now.to_i is passed to it. Reported-by: Jeremy Evans <jeremyevans0@gmail.com> [1] - gettimeofday() from Time.now is not a real syscall on VDSO-enabled x86_64 GNU/Linux systems where Unicorn is primarily developed.
-rw-r--r-- | lib/unicorn.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb index d63567f..13c203a 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -575,13 +575,13 @@ module Unicorn nr = 0 # this becomes negative if we need to reopen logs alive = worker.tmp # tmp is our lifeline to the master process ready = LISTENERS - t = ti = 0 # closing anything we IO.select on will raise EBADF trap(:USR1) { nr = -65536; SELF_PIPE.first.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" + m = 0 begin nr < 0 and reopen_worker_logs(worker.nr) @@ -595,13 +595,13 @@ module Unicorn # changes with chmod doesn't update ctime on all filesystems; so # we change our counter each and every time (after process_client # and before IO.select). - t == (ti = Time.now.to_i) or alive.chmod(t = ti) + alive.chmod(m = 0 == m ? 1 : 0) ready.each do |sock| begin process_client(sock.accept_nonblock) nr += 1 - t == (ti = Time.now.to_i) or alive.chmod(t = ti) + alive.chmod(m = 0 == m ? 1 : 0) rescue Errno::EAGAIN, Errno::ECONNABORTED end break if nr < 0 @@ -614,7 +614,7 @@ module Unicorn redo unless nr == 0 # (nr < 0) => reopen logs ppid == Process.ppid or return - alive.chmod(t = 0) + alive.chmod(m = 0 == m ? 1 : 0) begin # timeout used so we can detect parent death: ret = IO.select(LISTENERS, nil, SELF_PIPE, timeout) or redo |