class PhusionPassenger::RequestHandler::ThreadHandler
This class encapsulates the logic of a single RequestHandler thread.
Constants
- CONTENT_LENGTH
- GC_SUPPORTS_CLEAR_STATS
- GC_SUPPORTS_TIME
- GET
- 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
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 63 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, :union_station_core, :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 94 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 100 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