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:
parent
d988094e4a
commit
4c2cd28747
3 changed files with 15 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue