about summary refs log tree commit homepage
path: root/lib/rainbows/fiber
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-26 00:41:26 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-26 13:41:06 -0800
commit278d9d5a7f3d2dc3c6563af1584b5e773e08073d (patch)
treea3066da21425c49f3ca89bb8cf3af2ab03c285d0 /lib/rainbows/fiber
parent1079dfa30108466d413f30526eda468cdf0ae985 (diff)
downloadrainbows-278d9d5a7f3d2dc3c6563af1584b5e773e08073d.tar.gz
Both FiberSpawn and FiberPool share similar main loops, the
only difference being the handling of connection acceptance.
So move the scheduler into it's own function for consistency.

We'll also correctly implement keepalive timeout so clients
get disconnected at the right time.
Diffstat (limited to 'lib/rainbows/fiber')
-rw-r--r--lib/rainbows/fiber/io.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rainbows/fiber/io.rb b/lib/rainbows/fiber/io.rb
index bc6c0fe..5c51cb9 100644
--- a/lib/rainbows/fiber/io.rb
+++ b/lib/rainbows/fiber/io.rb
@@ -36,13 +36,13 @@ module Rainbows
 
       # used for reading headers (respecting keepalive_timeout)
       def read_timeout
-        expire = false
+        expire = nil
         begin
           to_io.read_nonblock(16384)
         rescue Errno::EAGAIN
           return if expire && expire < Time.now
           RD[self] = false
-          expire = Time.now + G.kato
+          expire ||= Time.now + G.kato
           ::Fiber.yield
           RD.delete(self)
           retry