From 70b056098c700fe04265b5b18af0c78c7380018a Mon Sep 17 00:00:00 2001 From: Alex Lance Date: Tue, 11 Oct 2016 11:46:52 +1100 Subject: [PATCH 1/2] Permit the first_data_timeout setting to be overridden in the DSL --- lib/puma/dsl.rb | 6 ++++++ lib/puma/server.rb | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index 576a7ac9ec..95c5602031 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -140,6 +140,12 @@ def persistent_timeout(seconds) @options[:persistent_timeout] = seconds end + # Define how long the tcp socket stays open, if no data has been received + # + def first_data_timeout(seconds) + @options[:first_data_timeout] = seconds + end + # Work around leaky apps that leave garbage in Thread locals # across requests # diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 727cfb1515..9582b9c0ee 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -64,12 +64,11 @@ def initialize(app, events=Events.stdio, options={}) @thread_pool = nil @persistent_timeout = options.fetch(:persistent_timeout, PERSISTENT_TIMEOUT) + @first_data_timeout = options.fetch(:first_data_timeout, FIRST_DATA_TIMEOUT) @binder = Binder.new(events) @own_binder = true - @first_data_timeout = FIRST_DATA_TIMEOUT - @leak_stack_on_error = true @options = options From dbfb23b31531ac055157367f5b6c435a49a4988e Mon Sep 17 00:00:00 2001 From: Alex Lance Date: Tue, 11 Oct 2016 14:37:08 +1100 Subject: [PATCH 2/2] Add option --- lib/puma/configuration.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index 116ded2815..a9ca86550b 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -183,7 +183,8 @@ def default_options :environment => lambda { ENV['RACK_ENV'] || "development" }, :rackup => DefaultRackup, :logger => STDOUT, - :persistent_timeout => Const::PERSISTENT_TIMEOUT + :persistent_timeout => Const::PERSISTENT_TIMEOUT, + :first_data_timeout => Const::FIRST_DATA_TIMEOUT } end