diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-05 20:16:18 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-05 20:16:35 -0700 |
commit | 09535c1bd412bd66f93723c2c1aa7aacc2e091c3 (patch) | |
tree | b31bf862247995887a41f06d23e62b416bbf461a /lib | |
parent | e4057cf951a32c3a29b66dae1c1abea7989889e8 (diff) | |
download | rainbows-09535c1bd412bd66f93723c2c1aa7aacc2e091c3.tar.gz |
Ensure we reset the per-thread time Thread.current[:t] with each connection so we don't timeout long-lived connections.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rainbows/base.rb | 3 | ||||
-rw-r--r-- | lib/rainbows/thread_pool.rb | 1 | ||||
-rw-r--r-- | lib/rainbows/thread_spawn.rb | 5 |
3 files changed, 3 insertions, 6 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index 07fb584..11c8c7c 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -24,7 +24,8 @@ module Rainbows env = {} remote_addr = TCPSocket === client ? client.peeraddr.last : LOCALHOST - begin + begin # loop + Thread.current[:t] = Time.now while ! hp.headers(env, buf) buf << client.readpartial(CHUNK_SIZE) end diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index a6269cd..fc44cac 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -79,7 +79,6 @@ module Rainbows ret.first.each do |sock| begin process_client(sock.accept_nonblock) - thr[:t] = Time.now rescue Errno::EAGAIN, Errno::ECONNABORTED end end diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb index 36968d8..af05476 100644 --- a/lib/rainbows/thread_spawn.rb +++ b/lib/rainbows/thread_spawn.rb @@ -44,10 +44,7 @@ module Rainbows rescue Errno::EINTR, Errno::ECONNABORTED next end - threads.add(Thread.new(c) { |c| - Thread.current[:t] = Time.now - process_client(c) - }) + threads.add(Thread.new(c) { |c| process_client(c) }) end end join_spawned_threads(threads) |