mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Merge pull request #2295 from looker/looker/thread_pool_count1
resolve waiting counter problem
This commit is contained in:
commit
a72c68b350
3 changed files with 24 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
### Master
|
||||
* Bugfixes
|
||||
* Resolve issue with threadpool waiting counter decrement when thread is killed
|
||||
|
||||
## 5.0.0
|
||||
|
||||
* Features
|
||||
|
|
|
@ -122,8 +122,11 @@ module Puma
|
|||
@out_of_band_pending = false
|
||||
end
|
||||
not_full.signal
|
||||
not_empty.wait mutex
|
||||
@waiting -= 1
|
||||
begin
|
||||
not_empty.wait mutex
|
||||
ensure
|
||||
@waiting -= 1
|
||||
end
|
||||
end
|
||||
|
||||
work = todo.shift
|
||||
|
|
|
@ -266,4 +266,19 @@ class TestThreadPool < Minitest::Test
|
|||
assert_equal 2, rescued.length
|
||||
refute rescued.compact.any?(&:alive?)
|
||||
end
|
||||
|
||||
def test_correct_waiting_count_for_killed_threads
|
||||
pool = new_pool(1, 1) { |_| }
|
||||
sleep 1
|
||||
|
||||
# simulate our waiting worker thread getting killed for whatever reason
|
||||
pool.instance_eval { @workers[0].kill }
|
||||
sleep 1
|
||||
pool.reap
|
||||
sleep 1
|
||||
|
||||
pool << 0
|
||||
sleep 1
|
||||
assert_equal 0, pool.backlog
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue