From a59778612a3b651d4a59f37ecfdbba606b4263a6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 4 Nov 2009 01:42:35 -0800 Subject: http_server: add one second to any requested timeout This is because our timeout implementations are less precise than Unicorn. Since we handle multiple clients with the same process, we sacrifice precision for performance and instead implement our fchmod heartbeats at a fixed rate, as doing fchmod() repeated for short-lived connections would hurt performance and we have to call fchmod even when connected clients are idle. --- lib/rainbows/http_server.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/rainbows/http_server.rb') diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb index b150ddc..c0877cd 100644 --- a/lib/rainbows/http_server.rb +++ b/lib/rainbows/http_server.rb @@ -20,6 +20,21 @@ module Rainbows @worker_connections ||= MODEL_WORKER_CONNECTIONS[@use] end + #:stopdoc: + # + # Add one second to the timeout since our fchmod heartbeat is less + # precise (and must be more conservative) than Unicorn does. We + # handle many clients per process and can't chmod on every + # connection we accept without wasting cycles. That added to the + # fact that we let clients keep idle connections open for long + # periods of time means we have to chmod at a fixed interval. + alias_method :set_timeout, :timeout= + undef_method :timeout= + def timeout=(nr) + set_timeout(nr + 1) + end + #:startdoc: + def use(*args) model = args.shift or return @use mod = begin -- cgit v1.2.3-24-ge0c7