diff options
-rw-r--r-- | lib/rainbows/fiber/base.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb index b731947..a056152 100644 --- a/lib/rainbows/fiber/base.rb +++ b/lib/rainbows/fiber/base.rb @@ -57,15 +57,17 @@ module Rainbows def schedule_sleepers max = nil now = Time.now + fibs = [] ZZ.delete_if { |fib, time| if now >= time - fib.resume + fibs << fib now = Time.now else max = time false end } + fibs.each { |fib| fib.resume } max.nil? || max > (now + 1) ? 1 : max - now end @@ -76,7 +78,7 @@ module Rainbows hp = HttpParser.new env = {} alive = true - remote_addr = TCPSocket === io ? io.peeraddr.last : LOCALHOST + remote_addr = Rainbows.addr(io) begin # loop while ! hp.headers(env, buf) |