# 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