diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-01-21 15:11:16 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-01-21 16:54:02 -0800 |
commit | fb24ca8f30edbf5086dbe288d4dd4fa213684236 (patch) | |
tree | a29e782fb2bbacfb3ffbb084da98f039fe2ed811 | |
parent | 43d6ec33c3dd7497e27127adfffeb94722fd4b8d (diff) | |
download | rainbows-fb24ca8f30edbf5086dbe288d4dd4fa213684236.tar.gz |
We'll lower our precision for keepalive timeouts a little and and reduce our Time object allocation rate.
-rw-r--r-- | lib/rainbows/epoll/client.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/rainbows/epoll/client.rb b/lib/rainbows/epoll/client.rb index ba9d576..f4e49dc 100644 --- a/lib/rainbows/epoll/client.rb +++ b/lib/rainbows/epoll/client.rb @@ -13,12 +13,15 @@ module Rainbows::Epoll::Client KATO.compare_by_identity if KATO.respond_to?(:compare_by_identity) KEEPALIVE_TIMEOUT = Rainbows.keepalive_timeout EP = Rainbows::Epoll::EP + @@last_expire = Time.now def self.expire + return if ((now = Time.now) - @@last_expire) < 1.0 if (ot = KEEPALIVE_TIMEOUT) >= 0 - ot = Time.now - ot + ot = now - ot KATO.delete_if { |client, time| time < ot and client.timeout! } end + @@last_expire = now end # only call this once @@ -36,7 +39,7 @@ module Rainbows::Epoll::Client on_read(rv) return if @wr_queue[0] || closed? when :wait_readable - KATO[self] = Time.now if :headers == @state + KATO[self] = @@last_expire if :headers == @state return EP.set(self, IN) else break |