From 01fbc4a7f2fd5b751b9183d11aa74aadaffd145b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 21 Jan 2011 17:34:21 -0800 Subject: ev_core: force input to be given to app_call No need to setting an ivar for most requests --- lib/rainbows/coolio/client.rb | 4 ++-- lib/rainbows/coolio/thread_client.rb | 4 ++-- lib/rainbows/epoll/client.rb | 4 ++-- lib/rainbows/ev_core.rb | 7 +++---- lib/rainbows/event_machine/client.rb | 4 ++-- lib/rainbows/never_block/event_machine.rb | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) (limited to 'lib/rainbows') diff --git a/lib/rainbows/coolio/client.rb b/lib/rainbows/coolio/client.rb index 0ccccff..f1f16d3 100644 --- a/lib/rainbows/coolio/client.rb +++ b/lib/rainbows/coolio/client.rb @@ -106,10 +106,10 @@ class Rainbows::Coolio::Client < Coolio::IO @state = :headers end - def app_call + def app_call input KATO.delete(self) disable if enabled? - @env[RACK_INPUT] = @input + @env[RACK_INPUT] = input @env[REMOTE_ADDR] = @_io.kgio_addr @env[ASYNC_CALLBACK] = method(:write_async_response) status, headers, body = catch(:async) { diff --git a/lib/rainbows/coolio/thread_client.rb b/lib/rainbows/coolio/thread_client.rb index b837115..abc11d2 100644 --- a/lib/rainbows/coolio/thread_client.rb +++ b/lib/rainbows/coolio/thread_client.rb @@ -5,10 +5,10 @@ RUBY_VERSION =~ %r{\A1\.8} and warn "Coolio and Threads do not mix well under Ruby 1.8" class Rainbows::Coolio::ThreadClient < Rainbows::Coolio::Client - def app_call + def app_call input KATO.delete(self) disable if enabled? - @env[RACK_INPUT] = @input + @env[RACK_INPUT] = input app_dispatch # must be implemented by subclass end diff --git a/lib/rainbows/epoll/client.rb b/lib/rainbows/epoll/client.rb index 490f38b..6bf12f1 100644 --- a/lib/rainbows/epoll/client.rb +++ b/lib/rainbows/epoll/client.rb @@ -49,8 +49,8 @@ module Rainbows::Epoll::Client rescue IOError end - def app_call # called by on_read() - @env[RACK_INPUT] = @input + def app_call input # called by on_read() + @env[RACK_INPUT] = input @env[REMOTE_ADDR] = kgio_addr status, headers, body = APP.call(@env.merge!(RACK_DEFAULTS)) ev_write_response(status, headers, body, @hp.next?) diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb index 826dce6..61853ab 100644 --- a/lib/rainbows/ev_core.rb +++ b/lib/rainbows/ev_core.rb @@ -83,8 +83,7 @@ module Rainbows::EvCore @hp.parse or return want_more @state = :body if 0 == @hp.content_length - @input = NULL_IO - app_call # common case + app_call NULL_IO # common case else # nil or len > 0 prepare_request_body end @@ -92,7 +91,7 @@ module Rainbows::EvCore if @hp.body_eof? if @hp.content_length @input.rewind - app_call + app_call @input else @state = :trailers on_read(data) @@ -107,7 +106,7 @@ module Rainbows::EvCore when :trailers if @hp.trailers(@env, @buf << data) @input.rewind - app_call + app_call @input else want_more end diff --git a/lib/rainbows/event_machine/client.rb b/lib/rainbows/event_machine/client.rb index 1b15daa..8c2549d 100644 --- a/lib/rainbows/event_machine/client.rb +++ b/lib/rainbows/event_machine/client.rb @@ -30,9 +30,9 @@ class Rainbows::EventMachine::Client < EM::Connection close_connection_after_writing end - def app_call + def app_call input set_comm_inactivity_timeout 0 - @env[RACK_INPUT] = @input + @env[RACK_INPUT] = input @env[REMOTE_ADDR] = @_io.kgio_addr @env[ASYNC_CALLBACK] = method(:write_async_response) @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new diff --git a/lib/rainbows/never_block/event_machine.rb b/lib/rainbows/never_block/event_machine.rb index e201492..be72ab6 100644 --- a/lib/rainbows/never_block/event_machine.rb +++ b/lib/rainbows/never_block/event_machine.rb @@ -1,7 +1,7 @@ # -*- encoding: binary -*- # :enddoc: class Rainbows::NeverBlock::Client < Rainbows::EventMachine::Client - def app_call + def app_call input POOL.spawn do begin super -- cgit v1.2.3-24-ge0c7