about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-04 01:42:35 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-04 23:03:21 -0800
commita59778612a3b651d4a59f37ecfdbba606b4263a6 (patch)
tree69dbdb04a65f17030576428887917b685f120363
parentb7041284279371ffe16de31880c19d48f6a624bb (diff)
downloadrainbows-a59778612a3b651d4a59f37ecfdbba606b4263a6.tar.gz
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.
-rw-r--r--lib/rainbows/http_server.rb15
1 files changed, 15 insertions, 0 deletions
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