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
|
## 5.0.0
|
||||||
|
|
||||||
* Features
|
* Features
|
||||||
|
|
|
@ -122,9 +122,12 @@ module Puma
|
||||||
@out_of_band_pending = false
|
@out_of_band_pending = false
|
||||||
end
|
end
|
||||||
not_full.signal
|
not_full.signal
|
||||||
|
begin
|
||||||
not_empty.wait mutex
|
not_empty.wait mutex
|
||||||
|
ensure
|
||||||
@waiting -= 1
|
@waiting -= 1
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
work = todo.shift
|
work = todo.shift
|
||||||
end
|
end
|
||||||
|
|
|
@ -266,4 +266,19 @@ class TestThreadPool < Minitest::Test
|
||||||
assert_equal 2, rescued.length
|
assert_equal 2, rescued.length
|
||||||
refute rescued.compact.any?(&:alive?)
|
refute rescued.compact.any?(&:alive?)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue