Fix out_of_band hook never executed when multiple worker threads (clo… #2178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Alternative solution to this PR: #2180
I believe this one should be merged and #2180 should be discarded but the maintainers are probably wiser than me on Puma!
Issue description
C.F. #2177
Fix description
Before this patch, the
out_of_band
hook was executed only when all worker threads were free:In addition, due to how the function
wait_until_not_full
(in lib/puma/thread_pool.rb) works, namely:The condition
if busy_threads == 0
could never be satisfied if the number of worker threads was > 1.EDIT: it could be satisfied if the worker finished its job before the call to
wait_until_not_full
, which is very unlikely because this function is called right after adding the client to the pool.I believe that the
out_of_band
hook should be allowed to run if there is at least 1 available worker thread. It seems reasonable to me and provides an easy fix for this bug.Your checklist for this pull request
[changelog skip]
the pull request title.[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.