From 1a9a718a3f9a5b582a4a339a9bb9249c2ca392d7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 6 Nov 2009 19:45:17 -0800 Subject: cleanup worker heartbeat and master deathwatch It turns out neither the EventMachine and Rev classes checked for master death in its heartbeat mechanism. Since we managed to forget the same thing twice, we now have a test case for it and also centralized the code to remove duplication. --- lib/rainbows/thread_pool.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/rainbows/thread_pool.rb') diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index 280ba40..7934dc8 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -28,16 +28,15 @@ module Rainbows def worker_loop(worker) init_worker_process(worker) pool = (1..worker_connections).map { new_worker_thread } - m = 0 - while G.alive && master_pid == Process.ppid + while G.alive + # if any worker dies, something is serious wrong, bail pool.each do |thr| - worker.tmp.chmod(m = 0 == m ? 1 : 0) - # if any worker dies, something is serious wrong, bail - thr.join(1) and break + G.tick + thr.join(1) and G.quit! end end - join_threads(pool, worker) + join_threads(pool) end def new_worker_thread -- cgit v1.2.3-24-ge0c7