From 9e62bc10294f0b6344b47cd596a93ae457d546fb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Nov 2011 15:13:15 -0800 Subject: configurator: limit timeout to 30 days There's no practical difference between a timeout of 30 days and 68 years from an HTTP server standpoint. POSIX limits us to 31 days, actually, but there could be rounding error with floats used in Ruby time calculations and there's no real difference between 30 and 31 days, either... Thanks to Jeremy Evans for pointing out large values will throw EINVAL (on select(2) under OpenBSD with Ruby 1.9.3 and RangeError on older Rubies. --- lib/unicorn/configurator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index a93c1dc..89cbf5c 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -188,7 +188,8 @@ class Unicorn::Configurator # } def timeout(seconds) set_int(:timeout, seconds, 3) - max = 0x7ffffffe # Rainbows! adds one second to this for safety + # POSIX says 31 days is the smallest allowed maximum timeout for select() + max = 30 * 60 * 60 * 24 set[:timeout] = seconds > max ? max : seconds end -- cgit v1.2.3-24-ge0c7