diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-12-01 22:39:38 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-12-01 22:39:38 -0800 |
commit | c50b69ddf0f1305bb39ed812d084f59db6dd9897 (patch) | |
tree | 4c2146f2fbc6fc00e6ba863cd6bf5e60c9d82840 /lib/rainbows.rb | |
parent | 1269cbb93d26ff938f443e8931e908481374bdc3 (diff) | |
download | rainbows-c50b69ddf0f1305bb39ed812d084f59db6dd9897.tar.gz |
We now correctly exit!(2) if our master can't kill us.
Diffstat (limited to 'lib/rainbows.rb')
-rw-r--r-- | lib/rainbows.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb index c8f77c0..9e07185 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -8,14 +8,16 @@ module Rainbows # global vars because class/instance variables are confusing me :< # this struct is only accessed inside workers and thus private to each # G.cur may not be used in the network concurrency model - class State < Struct.new(:alive,:m,:cur,:kato,:server,:tmp) + class State < Struct.new(:alive,:m,:cur,:kato,:server,:tmp,:expire) def tick tmp.chmod(self.m = m == 0 ? 1 : 0) + exit!(2) if expire && Time.now >= expire alive && server.master_pid == Process.ppid or quit! end def quit! self.alive = false + self.expire ||= Time.now + (server.timeout * 2.0) server.class.const_get(:LISTENERS).map! { |s| s.close rescue nil } false end |