From 0a10915fff80ff90bdef2a905dfdc589e815aefd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Nov 2015 03:58:05 +0000 Subject: bump to unicorn 5.0.1, use monotonic clock The timeout (mis)feature in unicorn uses the monotonic clock if available. We must follow suit to avoid having our timeout functionality completely broken. --- lib/rainbows/thread_timeout.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/rainbows/thread_timeout.rb') diff --git a/lib/rainbows/thread_timeout.rb b/lib/rainbows/thread_timeout.rb index 8348272..8739d29 100644 --- a/lib/rainbows/thread_timeout.rb +++ b/lib/rainbows/thread_timeout.rb @@ -63,7 +63,7 @@ class Rainbows::ThreadTimeout # The MRI 1.8 won't be usable in January 2038, we'll raise this # when we eventually drop support for 1.8 (before 2038, hopefully) - NEVER = Time.at(0x7fffffff) + NEVER = 0x7fffffff def initialize(app, opts) # @timeout must be Numeric since we add this to Time @@ -114,7 +114,7 @@ class Rainbows::ThreadTimeout # is hopeless and we might as well just die anyways. # initialize guarantees @timeout will be Numeric start_watchdog(env) unless @watchdog - @active[Thread.current] = Time.now + @timeout + @active[Thread.current] = Rainbows.now + @timeout begin # It is important to unlock inside this begin block @@ -162,7 +162,7 @@ class Rainbows::ThreadTimeout # that are about to release themselves from the eye of the # watchdog thread. @lock.synchronize do - now = Time.now + now = Rainbows.now @active.delete_if do |thread, expire_at| # We also use this loop to get the maximum possible time to # sleep for if we're not killing the thread. @@ -184,7 +184,7 @@ class Rainbows::ThreadTimeout sleep(@timeout) else # sleep until the next known thread is about to expire. - sec = next_expiry - Time.now + sec = next_expiry - Rainbows.now sec > 0.0 ? sleep(sec) : Thread.pass # give other threads a chance end rescue => e -- cgit v1.2.3-24-ge0c7