Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix looping forever at 100% CPU if socket is closed #10658

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/http/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -454,18 +454,20 @@ class HTTP::Server

@sockets.each do |socket|
spawn do
until closed?
loop do
io = begin
socket.accept?
rescue e
handle_exception(e)
nil
next
end

if io
# a non nillable version of the closured io
_io = io
spawn handle_client(_io)
else
break
end
end
ensure
Expand Down