From 32affaf3d70983b86ec006ece27f3f34c98bedcc Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 10 May 2009 19:02:05 -0700 Subject: Enforce minimum timeout at 3 seconds 2 seconds is still prone to race conditions under high load. We're intentionally less accurate than we could be in order to reduce syscall and method dispatch overhead. --- lib/unicorn/configurator.rb | 4 ++-- test/unit/test_signals.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 64647a3..a432f64 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -145,11 +145,11 @@ module Unicorn # timeout is enforced by the master process itself and not subject # to the scheduling limitations by the worker process. Due the # low-complexity, low-overhead implementation, timeouts of less - # than 2.0 seconds can be considered inaccurate and unsafe. + # than 3.0 seconds can be considered inaccurate and unsafe. def timeout(seconds) Numeric === seconds or raise ArgumentError, "not numeric: timeout=#{seconds.inspect}" - seconds >= 2 or raise ArgumentError, + seconds >= 3 or raise ArgumentError, "too low: timeout=#{seconds.inspect}" @set[:timeout] = seconds end diff --git a/test/unit/test_signals.rb b/test/unit/test_signals.rb index 24094fe..ef66ed6 100644 --- a/test/unit/test_signals.rb +++ b/test/unit/test_signals.rb @@ -40,7 +40,7 @@ class SignalsTest < Test::Unit::TestCase def test_worker_dies_on_dead_master pid = fork { app = lambda { |env| [ 200, {'X-Pid' => "#$$" }, [] ] } - opts = @server_opts.merge(:timeout => 2) + opts = @server_opts.merge(:timeout => 3) redirect_test_io { HttpServer.new(app, opts).start.join } } child = sock = buf = t0 = nil @@ -94,7 +94,7 @@ class SignalsTest < Test::Unit::TestCase def test_timeout_slow_response pid = fork { app = lambda { |env| sleep } - opts = @server_opts.merge(:timeout => 2) + opts = @server_opts.merge(:timeout => 3) redirect_test_io { HttpServer.new(app, opts).start.join } } t0 = Time.now -- cgit v1.2.3-24-ge0c7