diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-11 20:42:21 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-11 20:53:19 -0700 |
commit | 90a03ee550741465ea43fd70e087851e17246fb6 (patch) | |
tree | aac5c0422e3ab17d652d96bc2cafd83fef5a8a23 /lib/rainbows/revactor.rb | |
parent | df204a05d3a5bda8f716fa9f51be464fa59a3af1 (diff) | |
download | rainbows-90a03ee550741465ea43fd70e087851e17246fb6.tar.gz |
Diffstat (limited to 'lib/rainbows/revactor.rb')
-rw-r--r-- | lib/rainbows/revactor.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index e1c52e3..fb35394 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -94,7 +94,7 @@ module Rainbows Actor.receive { |filter| filter.when(:resume) {} } end actor = Actor.spawn(l.accept) { |c| process_client(c) } - clients[actor.object_id] = false + clients[actor.object_id] = actor root.link(actor) rescue Errno::EAGAIN, Errno::ECONNABORTED rescue Errno::EBADF @@ -106,18 +106,24 @@ module Rainbows end m = 0 - begin + check_quit = lambda do worker.tmp.chmod(m = 0 == m ? 1 : 0) - if listeners.any? { |l| l.dead? } || master_pid != Process.ppid + if listeners.any? { |l| l.dead? } || + master_pid != Process.ppid || + LISTENERS.first.nil? alive = false - clients.each_pair { |a,_| a[:quit] = true } + clients.each_value { |a| a[:quit] = true } end + end + + begin Actor.receive do |filter| - filter.after(timeout) { redo } + filter.after(timeout, &check_quit) filter.when(Case[:exit, Actor, Object]) do |_,actor,_| orig = clients.size clients.delete(actor.object_id) orig >= limit and listeners.each { |l| l << :resume } + check_quit.call end end end while alive || clients.size > 0 |