Sha256: a3ec3f35f9ee37c5cf2a58d0126289e13d04ca1339dba106551ea54c5b8ca77b

Contents?: true

Size: 929 Bytes

Versions: 14

Compression:

Stored size: 929 Bytes

Contents

# -*- encoding: binary -*-
# :enddoc:

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 input
    KATO.delete(self)
    disable if enabled?
    @env[RACK_INPUT] = input
    app_dispatch # must be implemented by subclass
  end

  # this is only called in the master thread
  def response_write(response)
    ev_write_response(*response, @hp.next?)
    rescue => e
      handle_error(e)
  end

  # fails-safe application dispatch, we absolutely cannot
  # afford to fail or raise an exception (killing the thread)
  # here because that could cause a deadlock and we'd leak FDs
  def app_response
    begin
      @env[REMOTE_ADDR] = @_io.kgio_addr
      APP.call(@env.merge!(RACK_DEFAULTS))
    rescue => e
      Rainbows::Error.app(e) # we guarantee this does not raise
      [ 500, {}, [] ]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rainbows-4.4.3 lib/rainbows/coolio/thread_client.rb
rainbows-4.4.2 lib/rainbows/coolio/thread_client.rb
rainbows-4.4.1.1.gd5c8c lib/rainbows/coolio/thread_client.rb
rainbows-4.4.1 lib/rainbows/coolio/thread_client.rb
rainbows-4.4.0 lib/rainbows/coolio/thread_client.rb
rainbows-4.3.1 lib/rainbows/coolio/thread_client.rb
rainbows-4.3.0 lib/rainbows/coolio/thread_client.rb
rainbows-4.2.0 lib/rainbows/coolio/thread_client.rb
rainbows-4.1.0 lib/rainbows/coolio/thread_client.rb
rainbows-4.0.0 lib/rainbows/coolio/thread_client.rb
rainbows-3.4.0 lib/rainbows/coolio/thread_client.rb
rainbows-3.3.0 lib/rainbows/coolio/thread_client.rb
rainbows-3.2.0 lib/rainbows/coolio/thread_client.rb
rainbows-3.1.0 lib/rainbows/coolio/thread_client.rb