0
@@ -20,7 +20,6 @@ require 'socket'
0
require 'passenger/message_channel'
0
require 'passenger/utils'
0
-require 'passenger/native_support'
0
# The request handler is the layer which connects Apache with the underlying application's
0
@@ -82,9 +81,9 @@ module Passenger
0
# and sends it to the request handler.
0
class AbstractRequestHandler
0
# Signal which will cause the Rails application to exit immediately.
0
- HARD_TERMINATION_SIGNAL = "
SIGTERM"
0
+ HARD_TERMINATION_SIGNAL = "
TERM"
0
# Signal which will cause the Rails application to exit as soon as it's done processing a request.
0
- SOFT_TERMINATION_SIGNAL = "
SIGUSR1"
0
+ SOFT_TERMINATION_SIGNAL = "
USR1"
0
MAX_HEADER_SIZE = 128 * 1024
0
@@ -133,7 +132,7 @@ class AbstractRequestHandler
0
def initialize(owner_pipe, options = {})
0
create_unix_socket_on_filesystem
0
- @socket.
fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)0
+ @socket.
close_on_exec!0
@owner_pipe = owner_pipe
0
@previous_signal_handlers = {}
0
@main_loop_thread_lock = Mutex.new
0
@@ -177,8 +176,8 @@ class AbstractRequestHandler
0
@graceful_termination_pipe = IO.pipe
0
- @graceful_termination_pipe[0].fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
0
- @graceful_termination_pipe[1].fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
0
+ @graceful_termination_pipe[0].close_on_exec!
0
+ @graceful_termination_pipe[1].close_on_exec!
0
@main_loop_thread_lock.synchronize do
0
@main_loop_running = true
0
@@ -252,8 +251,13 @@ private
0
+ if defined?(NativeSupport)
0
+ unix_path_max = NativeSupport::UNIX_PATH_MAX
0
@socket_name = "#{passenger_tmpdir}/passenger_backend.#{generate_random_id(:base64)}"
0
- @socket_name = @socket_name.slice(0,
NativeSupport::UNIX_PATH_MAX - 1)
0
+ @socket_name = @socket_name.slice(0,
unix_path_max - 1)
0
@socket = UNIXServer.new(@socket_name)
0
File.chmod(0600, @socket_name)
0
@@ -267,7 +271,7 @@ private
0
# special handlers for a few signals. The previous signal handlers
0
# will be put back by calling revert_signal_handlers.
0
def reset_signal_handlers
0
- Signal.list
.each_key do |signal|
0
+ Signal.list
_trappable.each_key do |signal|
0
prev_handler = trap(signal, DEFAULT)
0
if prev_handler != DEFAULT
0
@@ -281,12 +285,16 @@ private
0
def install_useful_signal_handlers
0
+ trappable_signals = Signal.list_trappable
0
trap(SOFT_TERMINATION_SIGNAL) do
0
@graceful_termination_pipe[1].close rescue nil
0
+ end if trappable_signals.has_key?(SOFT_TERMINATION_SIGNAL)
0
raise SignalException, "SIGABRT"
0
+ end if trappable_signals.has_key?('ABRT')
0
if Kernel.respond_to?(:caller_for_all_threads)
0
output = "========== Process #{Process.pid}: backtrace dump ==========\n"
0
@@ -325,7 +333,7 @@ private
0
ios = select([@socket, @owner_pipe, @graceful_termination_pipe[0]]).first
0
if ios.include?(@socket)
0
client = @socket.accept
0
- client.
fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)0
# The real input stream is not seekable (calling _seek_
0
# or _rewind_ on it will raise an exception). But some
Comments
No one has commented yet.