### Home Classes Methods

### In Files

- lib/phusion_passenger/request_handler/thread_handler.rb

### Parent

Object

### Namespace

- CLASS PhusionPassenger::RequestHandler::ThreadHandler::Interrupted

### Methods

- ::new
- #install
- #main_loop

### Included Modules

- PhusionPassenger::DebugLogging
- PhusionPassenger::Utils

### Class/Module Index

Quicksearch

- PhusionPassenger
- PhusionPassenger::AbstractInstaller
- PhusionPassenger::AbstractInstaller::Abort
- PhusionPassenger::AbstractInstaller::CommandError
- PhusionPassenger::AdminTools
- PhusionPassenger::AdminTools::MemoryStats
- PhusionPassenger::AdminTools::MemoryStats::Process
- PhusionPassenger::AdminTools::ServerInstance
- PhusionPassenger::AdminTools::ServerInstance::CorruptedDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::GenerationsAbsentError
- PhusionPassenger::AdminTools::ServerInstance::Group
- PhusionPassenger::AdminTools::ServerInstance::Process
- PhusionPassenger::AdminTools::ServerInstance::RoleDeniedError
- PhusionPassenger::AdminTools::ServerInstance::StaleDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::Stats
- PhusionPassenger::AdminTools::ServerInstance::UnsupportedGenerationStructureVersionError
- PhusionPassenger::AnalyticsLogger
- PhusionPassenger::AnalyticsLogger::Connection
- PhusionPassenger::AnalyticsLogger::Lock
- PhusionPassenger::AnalyticsLogger::Log
- PhusionPassenger::ClassicRails
- PhusionPassenger::ClassicRails::CGIFixed
- PhusionPassenger::ClassicRails::ThreadHandlerExtension
- PhusionPassenger::ConsoleTextTemplate
- PhusionPassenger::DebugLogging
- PhusionPassenger::LoaderSharedHelpers
- PhusionPassenger::MessageChannel
- PhusionPassenger::MessageChannel::InvalidHashError
- PhusionPassenger::MessageClient
- PhusionPassenger::NativeSupportLoader
- PhusionPassenger::Packaging
- PhusionPassenger::PlatformInfo
- PhusionPassenger::PlatformInfo::Depcheck
- PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner
- PhusionPassenger::PlatformInfo::Depcheck::Dependency
- PhusionPassenger::PlatformInfo::RuntimeError
- PhusionPassenger::Plugin
- PhusionPassenger::PreloaderSharedHelpers
- PhusionPassenger::Rack
- PhusionPassenger::Rack::OutOfBandGc
- PhusionPassenger::Rack::ThreadHandlerExtension
- PhusionPassenger::Rails3Extensions
- PhusionPassenger::Rails3Extensions::AnalyticsLogging
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger
- PhusionPassenger::RequestHandler
- PhusionPassenger::RequestHandler::ThreadHandler
- PhusionPassenger::RequestHandler::ThreadHandler::Interrupted
- PhusionPassenger::SharedConstants
- PhusionPassenger::Standalone
- PhusionPassenger::Standalone::AppFinder
- PhusionPassenger::Standalone::Command
- PhusionPassenger::Standalone::ConfigFile
- PhusionPassenger::Standalone::ConfigFile::DisallowedContextError
- PhusionPassenger::Standalone::HelpCommand
- PhusionPassenger::Standalone::Main
- PhusionPassenger::Standalone::PackageRuntimeCommand
- PhusionPassenger::Standalone::RuntimeInstaller
- PhusionPassenger::Standalone::StartCommand
- PhusionPassenger::Standalone::StatusCommand
- PhusionPassenger::Standalone::StopCommand
- PhusionPassenger::Standalone::Utils
- PhusionPassenger::Standalone::VersionCommand
- PhusionPassenger::Utils
- PhusionPassenger::Utils::AnsiColors
- PhusionPassenger::Utils::FileSystemWatcher
- PhusionPassenger::Utils::FileSystemWatcher::DirInfo
- PhusionPassenger::Utils::FileSystemWatcher::FileInfo
- PhusionPassenger::Utils::HostsFileParser
- PhusionPassenger::Utils::TeeInput
- PhusionPassenger::Utils::TmpIO
- PhusionPassenger::Utils::UnseekableSocket
- CommonLibraryBuilder
- Exception
- GC
- IO
- Object
- Signal

No matching classes.

# PhusionPassenger::RequestHandler::ThreadHandler

This class encapsulates the logic of a single RequestHandler thread.

### Constants

CONTENT_LENGTH
GC_SUPPORTS_CLEAR_STATS
GC_SUPPORTS_TIME
MAX_HEADER_SIZE
OBJECT_SPACE_SUPPORTS_ALLOCATED_OBJECTS
OBJECT_SPACE_SUPPORTS_COUNT_OBJECTS
OBJECT_SPACE_SUPPORTS_LIVE_OBJECTS
OOBW
PASSENGER_CONNECT_PASSWORD
PING
REQUEST_METHOD
TRANSFER_ENCODING

### Attributes

interruptable[R]
iteration[R]
stats_mutex[R]
thread[R]

### Public Class Methods

new(request_handler, options = {}) click to toggle source

    # File lib/phusion_passenger/request_handler/thread_handler.rb, line 62
    def initialize(request_handler, options = {})
            @request_handler   = request_handler
            @server_socket     = Utils.require_option(options, :server_socket)
            @socket_name       = Utils.require_option(options, :socket_name)
            @protocol          = Utils.require_option(options, :protocol)
            @app_group_name    = Utils.require_option(options, :app_group_name)
            Utils.install_options_as_ivars(self, options,
                    :app,
                    :analytics_logger,
                    :connect_password
            )

            @stats_mutex   = Mutex.new
            @interruptable = false
            @iteration     = 0

            if @protocol == :session
                    metaclass = class << self; self; end
                    metaclass.class_eval do
                            alias parse_request parse_session_request
                    end
            elsif @protocol == :http
                    metaclass = class << self; self; end
                    metaclass.class_eval do
                            alias parse_request parse_http_request
                    end
            else
                    raise ArgumentError, "Unknown protocol specified"
            end
    end

### Public Instance Methods

install() click to toggle source

    # File lib/phusion_passenger/request_handler/thread_handler.rb, line 93
    def install
            @thread = Thread.current
            Thread.current[:passenger_thread_handler] = self
            PhusionPassenger.call_event(:starting_request_handler_thread)
    end

main_loop(finish_callback) click to toggle source

    # File lib/phusion_passenger/request_handler/thread_handler.rb, line 99
    def main_loop(finish_callback)
            socket_wrapper = Utils::UnseekableSocket.new
            channel        = MessageChannel.new
            buffer         = ''
            buffer.force_encoding('binary') if buffer.respond_to?(:force_encoding)

            begin
                    finish_callback.call
                    while true
                            hijacked = accept_and_process_next_request(socket_wrapper, channel, buffer)
                            socket_wrapper = Utils::UnseekableSocket.new if hijacked
                    end
            rescue Interrupted
                    # Do nothing.
            end
            debug("Thread handler main loop exited normally")
    ensure
            @stats_mutex.synchronize { @interruptable = true }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.