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

Merge pull request #1563 from dannyfallon/df/threadpool-race-fix

Meter accept(2) while taking into account races around thread pool mutex
This commit is contained in:
Richard Schneeman 2018-05-01 16:55:34 -05:00 committed by GitHub
commit 3f0b725488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -157,12 +157,12 @@ module Puma
@mutex.synchronize do
while true
return if @shutdown
return if @waiting > 0
# If we can still spin up new threads and there
# is work queued, then accept more work until we would
# is work queued that cannot be handled by waiting
# threads, then accept more work until we would
# spin up the max number of threads.
return if @todo.size < @max - @spawned
return if @todo.size - @waiting < @max - @spawned
@not_full.wait @mutex
end