about summary refs log tree commit homepage
path: root/lib/rainbows/thread_spawn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-06 19:45:17 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-06 19:45:17 -0800
commit1a9a718a3f9a5b582a4a339a9bb9249c2ca392d7 (patch)
tree0c95f2d8fc4de8542f7716832800614e1e7a8872 /lib/rainbows/thread_spawn.rb
parente1dcadef6ca242e36e99aab19e3e040bf01070f9 (diff)
downloadrainbows-1a9a718a3f9a5b582a4a339a9bb9249c2ca392d7.tar.gz
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.
Diffstat (limited to 'lib/rainbows/thread_spawn.rb')
-rw-r--r--lib/rainbows/thread_spawn.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb
index 39934a6..a3068c9 100644
--- a/lib/rainbows/thread_spawn.rb
+++ b/lib/rainbows/thread_spawn.rb
@@ -22,21 +22,18 @@ module Rainbows
     def worker_loop(worker)
       init_worker_process(worker)
       threads = ThreadGroup.new
-      alive = worker.tmp
-      m = 0
       limit = worker_connections
 
       begin
-        G.alive && master_pid == Process.ppid or break
         ret = begin
-          alive.chmod(m = 0 == m ? 1 : 0)
+          G.tick or break
           IO.select(LISTENERS, nil, nil, 1) or next
         rescue Errno::EINTR
           retry
         rescue Errno::EBADF, TypeError
           break
         end
-        alive.chmod(m = 0 == m ? 1 : 0)
+        G.tick
 
         ret.first.each do |l|
           # Sleep if we're busy, another less busy worker process may
@@ -57,7 +54,7 @@ module Rainbows
       rescue Object => e
         listen_loop_error(e)
       end while true
-      join_threads(threads.list, worker)
+      join_threads(threads.list)
     end
 
   end