diff options
author | Matthew Draper <matthew@trebex.net> | 2017-07-12 03:51:04 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-12 03:51:04 +0930 |
commit | 978ca2895e1ab7d781e26cd88f7b822bd50f321e (patch) | |
tree | 420fd73267755145a072c482c7ecc9c3dfe072d2 /lib/rack/lock.rb | |
parent | 0362a54dba92626582d42f3343c209b7cdb7e713 (diff) | |
parent | 7fa67d8c02719b67f792eae2f1024c6b64a804ba (diff) | |
download | rack-978ca2895e1ab7d781e26cd88f7b822bd50f321e.tar.gz |
Merge pull request #1189 from lugray/fix_rack_lock
Stop replacing the environment in Rack::Lock
Diffstat (limited to 'lib/rack/lock.rb')
-rw-r--r-- | lib/rack/lock.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/rack/lock.rb b/lib/rack/lock.rb index 923dca59..b5a41e8e 100644 --- a/lib/rack/lock.rb +++ b/lib/rack/lock.rb @@ -11,12 +11,21 @@ module Rack def call(env) @mutex.lock + @env = env + @old_rack_multithread = env[RACK_MULTITHREAD] begin - response = @app.call(env.merge(RACK_MULTITHREAD => false)) - returned = response << BodyProxy.new(response.pop) { @mutex.unlock } + response = @app.call(env.merge!(RACK_MULTITHREAD => false)) + returned = response << BodyProxy.new(response.pop) { unlock } ensure - @mutex.unlock unless returned + unlock unless returned end end + + private + + def unlock + @mutex.unlock + @env[RACK_MULTITHREAD] = @old_rack_multithread + end end end |