Skip to content

Commit

Permalink
Config first data timeout (#1111)
Browse files Browse the repository at this point in the history
* Permit the first_data_timeout setting to be overridden in the DSL

* Add option
  • Loading branch information
alexlance authored and nateberkopec committed Jun 4, 2017
1 parent 65a51b5 commit 4af4a00
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/puma/configuration.rb
Expand Up @@ -183,7 +183,8 @@ def puma_default_options
:environment => ->{ 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

Expand Down
6 changes: 6 additions & 0 deletions lib/puma/dsl.rb
Expand Up @@ -132,6 +132,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
#
Expand Down
3 changes: 1 addition & 2 deletions lib/puma/server.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4af4a00

Please sign in to comment.