Sha256: c27bb866412414b37a0cb6b70207a5081cff52e7f5fccccddd4ab9f96100e2f3

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 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)
    return hijacked if @hp.hijacked?
    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
      @hp.hijack_setup(@env, @_io)
      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

6 entries across 6 versions & 1 rubygems

Version Path
rainbows-4.7.0 lib/rainbows/coolio/thread_client.rb
rainbows-4.6.2 lib/rainbows/coolio/thread_client.rb
rainbows-4.6.1 lib/rainbows/coolio/thread_client.rb
rainbows-4.6.0.4.g4108 lib/rainbows/coolio/thread_client.rb
rainbows-4.6.0 lib/rainbows/coolio/thread_client.rb
rainbows-4.5.0 lib/rainbows/coolio/thread_client.rb