Skip to content

Commit

Permalink
move thread var init closer to its use (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
toregeschliman authored May 15, 2024
1 parent fdb2a74 commit 5fc73d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/timeout/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def initialize(app, service_timeout:nil, wait_timeout:nil, wait_overtime:nil, se
@wait_overtime = read_timeout_property wait_overtime, ENV.fetch("RACK_TIMEOUT_WAIT_OVERTIME", 60).to_i
@service_past_wait = service_past_wait == "not_specified" ? ENV.fetch("RACK_TIMEOUT_SERVICE_PAST_WAIT", false).to_s != "false" : service_past_wait

Thread.main['RACK_TIMEOUT_COUNT'] ||= 0
if @term_on_timeout && !::Process.respond_to?(:fork)
raise(NotImplementedError, <<-MSG)
The platform running your application does not support forking (i.e. Windows, JVM, etc).
Expand Down Expand Up @@ -137,6 +136,7 @@ def call(env)
message << "waited #{info.ms(:wait)}, then " if info.wait
message << "ran for longer than #{info.ms(:timeout)} "
if term_on_timeout
Thread.main['RACK_TIMEOUT_COUNT'] ||= 0
Thread.main['RACK_TIMEOUT_COUNT'] += 1

if Thread.main['RACK_TIMEOUT_COUNT'] >= @term_on_timeout
Expand Down

0 comments on commit 5fc73d3

Please sign in to comment.