diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-11 02:35:48 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-11 02:44:28 -0700 |
commit | 4f8ae9abbb985a4091acbb7f57fb7f88fa2d43ba (patch) | |
tree | 44137cb0fc771bd86fe1f487901dcf3f131e124e /lib/rainbows/revactor.rb | |
parent | 512fd193d9f0e83d0233d239172b15915652f351 (diff) | |
download | rainbows-4f8ae9abbb985a4091acbb7f57fb7f88fa2d43ba.tar.gz |
Avoid overloading the "alive" variable here and wakeup less frequently as well to do the fchmod.
Diffstat (limited to 'lib/rainbows/revactor.rb')
-rw-r--r-- | lib/rainbows/revactor.rb | 15 |
1 files changed, 7 insertions, 8 deletions
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 |