1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Close idle connections immediately on shutdown (#2460)

This commit is contained in:
Chris LaRose 2020-10-27 06:51:26 -07:00 committed by GitHub
parent d988094e4a
commit 4c2cd28747
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View file

@ -8,6 +8,7 @@
* Bugfixes
* Your bugfix goes here <Most recent on the top, like GitHub> (#Github Number)
* Ignore illegal (by Rack spec) response header (#2439)
* Close idle connections immediately on shutdown (#2460)
## 5.0.3 / 2020-10-26

View file

@ -239,13 +239,8 @@ module Puma
# @version 5.0.0
#
def can_close?
# Allow connection to close if it's received at least one full request
# and hasn't received any data for a future request.
#
# From RFC 2616 section 8.1.4:
# Servers SHOULD always respond to at least one request per connection,
# if at all possible.
@requests_served > 0 && @parsed_bytes == 0
# Allow connection to close if we're not in the middle of parsing a request.
@parsed_bytes == 0
end
private

View file

@ -1143,6 +1143,18 @@ EOF
assert_empty @events.stdout.string
end
def test_idle_connections_closed_immediately_on_shutdown
server_run
sock = new_connection
sleep 0.5 # give enough time for new connection to enter reactor
@server.stop false
assert IO.select([sock], nil, nil, 1), 'Unexpected timeout'
assert_raises EOFError do
sock.read_nonblock(256)
end
end
def test_run_stop_thread_safety
100.times do
thread = @server.run