From 4f8ae9abbb985a4091acbb7f57fb7f88fa2d43ba Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 11 Oct 2009 02:35:48 -0700 Subject: revactor: continue fchmod beat in graceful exit Avoid overloading the "alive" variable here and wakeup less frequently as well to do the fchmod. --- lib/rainbows/revactor.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 13c142f..e1c52e3 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -84,7 +84,7 @@ module Rainbows limit = worker_connections revactorize_listeners! clients = {} - alive = worker.tmp + alive = true listeners = LISTENERS.map do |s| Actor.spawn(s) do |l| @@ -107,20 +107,19 @@ module Rainbows m = 0 begin + worker.tmp.chmod(m = 0 == m ? 1 : 0) + if listeners.any? { |l| l.dead? } || master_pid != Process.ppid + alive = false + clients.each_pair { |a,_| a[:quit] = true } + end Actor.receive do |filter| - filter.after(1) do - alive.chmod(m = 0 == m ? 1 : 0) - if listeners.any? { |l| l.dead? } || master_pid != Process.ppid - alive = false - end - end + filter.after(timeout) { redo } filter.when(Case[:exit, Actor, Object]) do |_,actor,_| orig = clients.size clients.delete(actor.object_id) orig >= limit and listeners.each { |l| l << :resume } end end - alive or clients.each_pair { |a,_| a[:quit] = true } end while alive || clients.size > 0 end -- cgit v1.2.3-24-ge0c7