diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-18 00:08:20 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-18 00:08:20 -0800 |
commit | fc931be708f8da823a484fe88da9251d9cc72949 (patch) | |
tree | 6b8196c01592dd0057eb97abdcc573a0f21c395b /lib/rainbows | |
parent | 85f56d09ae9d9c2e2a28502312f2f3e5ec655693 (diff) | |
download | rainbows-fc931be708f8da823a484fe88da9251d9cc72949.tar.gz |
We'll be getting a keepalive_timeout setting soon, clients with 300 second idle keepalives are ridiculous and Ruby objects are still not that cheap in 1.9
Diffstat (limited to 'lib/rainbows')
-rw-r--r-- | lib/rainbows/revactor.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 43dc60d..4cf6f11 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -23,21 +23,28 @@ module Rainbows module Revactor require 'rainbows/revactor/tee_input' + RD_ARGS = { :timeout => 5 } + include Base # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response def process_client(client) - buf = client.read or return # this probably does not happen... + rd_args = [ nil ] + remote_addr = if ::Revactor::TCP::Socket === client + rd_args << RD_ARGS + client.remote_addr + else + LOCALHOST + end + buf = client.read(*rd_args) hp = HttpParser.new env = {} alive = true - remote_addr = ::Revactor::TCP::Socket === client ? - client.remote_addr : LOCALHOST begin while ! hp.headers(env, buf) - buf << client.read + buf << client.read(*rd_args) end env[Const::RACK_INPUT] = 0 == hp.content_length ? @@ -57,6 +64,8 @@ module Rainbows HttpResponse.write(client, response, out) end while alive and hp.reset.nil? and env.clear client.close + rescue ::Revactor::TCP::ReadError + client.close rescue => e handle_error(client, e) end |