From 42747db815ad668b20849afb2a9dcdd1319713ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 2 Nov 2010 12:32:23 -0700 Subject: avoid Errno::EAGAIN, harder Errno::EAGAIN is still a problem under Ruby 1.9.2, so try harder to avoid it and use kgio methods. Even when 1.9.3 is available, kgio will still be faster as exceptions are slower than normal return values. --- lib/rainbows/process_client.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/rainbows/process_client.rb') diff --git a/lib/rainbows/process_client.rb b/lib/rainbows/process_client.rb index d2c9d0e..d66c1ae 100644 --- a/lib/rainbows/process_client.rb +++ b/lib/rainbows/process_client.rb @@ -9,10 +9,6 @@ module Rainbows::ProcessClient TeeInput = Rainbows::TeeInput include Rainbows::Const - def wait_headers_readable(client) - IO.select([client], nil, nil, G.kato) - end - # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response # this is used by synchronous concurrency models @@ -25,8 +21,8 @@ module Rainbows::ProcessClient begin # loop until env = hp.parse - wait_headers_readable(client) or return - buf << client.kgio_read!(16384) + client.timed_read(buf2 ||= "") or return + buf << buf2 end env[CLIENT_IO] = client -- cgit v1.2.3-24-ge0c7