mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Ensure close
is called on the response body no matter what
Another fallout from https://github.com/puma/puma/pull/2809 is that in some cases the `res_body.close` wasn't called because some previous code raised. For Rails apps it means CurrentAttributes and a few other important states aren't reset properly. This is being improved on the Rails side too, but I believe it would be good to harden this on the puma side as well.
This commit is contained in:
parent
15dd1166ac
commit
b70f451fe8
1 changed files with 9 additions and 4 deletions
|
@ -171,11 +171,16 @@ module Puma
|
|||
end
|
||||
|
||||
ensure
|
||||
begin
|
||||
uncork_socket io
|
||||
|
||||
body.close
|
||||
client.tempfile.unlink if client.tempfile
|
||||
ensure
|
||||
# Whatever happens, we MUST call `close` on the response body.
|
||||
# Otherwise Rack::BodyProxy callbacks may not fire and lead to various state leaks
|
||||
res_body.close if res_body.respond_to? :close
|
||||
end
|
||||
|
||||
after_reply.each { |o| o.call }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue