Skip to content

Commit

Permalink
Don't double-interrupt the test HTTP server
Browse files Browse the repository at this point in the history
Copied from my PR to fix this double-interrupt race.

See ruby/net-http#197
  • Loading branch information
headius committed Dec 10, 2024
1 parent 6d6ea6c commit f07fc25
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/mri/net/http/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ def initialize(config, &block)
def start
@thread = Thread.new do
loop do
socket = @ssl_server ? @ssl_server.accept : @server.accept
socket = (@ssl_server || @server).accept
run(socket)
rescue
ensure
socket.close if socket
socket&.close
end
ensure
(@ssl_server || @server).close
end
end

Expand All @@ -42,7 +44,6 @@ def run(socket)

def shutdown
@thread&.kill
@server&.close
@thread&.join
end

Expand Down

0 comments on commit f07fc25

Please sign in to comment.