Commit d5568e40 authored by Jeff Trawick's avatar Jeff Trawick
Browse files

merge from trunk:

  Worker MPM: On graceless shutdown or restart, send signals to
  each worker thread to wake them up if they're polling on a
  Keep-Alive connection.  PR 38737.  [Chris Darroch]

PR: 38737
Reviewed by: chrisd, trawick, niq



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@424876 13f79535-47bb-0310-9956-ffa450edef68
parent 1578d0b1
Loading
Loading
Loading
Loading
+4 −0
Changes for CHANGES: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
                                                        -*- coding: utf-8 -*-
Changes with Apache 2.2.3
  *) Worker MPM: On graceless shutdown or restart, send signals to
     each worker thread to wake them up if they're polling on a
     Keep-Alive connection.  PR 38737.  [Chris Darroch]
  *) worker and event MPMs: fix excessive forking if fork() or child_init 
     take a long time.  PR 39275.
     [Greg Ames, Jeff Trawick, Chris Darroch <chrisd pearsoncmg.com> ]
+0 −9
Changes for STATUS: 0 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -76,15 +76,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
  [ start all new proposals below, under PATCHES PROPOSED. ]

    * Worker MPM: On graceless shutdown or restart, send signals to
      each worker thread to wake them up if they're polling on a
      Keep-Alive connection.  PR 38737.
        Trunk version of patch:
          http://svn.apache.org/viewvc?view=rev&revision=409715
        2.2.x version of patch:
          http://issues.apache.org/bugzilla/attachment.cgi?id=18355
      +1: chrisd, trawick, niq

    * mod_cache: Make caching of reverse SSL proxies possible again.
      PR 39593.
        Trunk version of patch:
+25 −0
Changes for server/mpm/worker/worker.c: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -213,6 +213,19 @@ static apr_proc_mutex_t *accept_mutex;
 */
#define LISTENER_SIGNAL     SIGHUP

/* The WORKER_SIGNAL signal will be sent from the main thread to the
 * worker threads during an ungraceful restart or shutdown.
 * This ensures that on systems (i.e., Linux) where closing the worker
 * socket doesn't awake the worker thread when it is polling on the socket
 * (especially in apr_wait_for_io_or_timeout() when handling
 * Keep-Alive connections), close_worker_sockets() and join_workers()
 * still function in timely manner and allow ungraceful shutdowns to
 * proceed to completion.  Otherwise join_workers() doesn't return
 * before the main process decides the child process is non-responsive
 * and sends a SIGKILL.
 */
#define WORKER_SIGNAL       AP_SIG_GRACEFUL

/* An array of socket descriptors in use by each thread used to
 * perform a non-graceful (forced) shutdown of the server. */
static apr_socket_t **worker_sockets;
@@ -821,6 +834,11 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
    ap_scoreboard_image->servers[process_slot][thread_slot].generation = ap_my_generation;
    ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);

#ifdef HAVE_PTHREAD_KILL
    unblock_signal(WORKER_SIGNAL);
    apr_signal(WORKER_SIGNAL, dummy_signal_handler);
#endif

    while (!workers_may_exit) {
        if (!is_idle) {
            rv = ap_queue_info_set_idle(worker_queue_info, last_ptrans);
@@ -1076,6 +1094,13 @@ static void join_workers(apr_thread_t *listener, apr_thread_t **threads)

    for (i = 0; i < ap_threads_per_child; i++) {
        if (threads[i]) { /* if we ever created this thread */
#ifdef HAVE_PTHREAD_KILL
            apr_os_thread_t *worker_os_thread;

            apr_os_thread_get(&worker_os_thread, threads[i]);
            pthread_kill(*worker_os_thread, WORKER_SIGNAL);
#endif

            rv = apr_thread_join(&thread_rv, threads[i]);
            if (rv != APR_SUCCESS) {
                ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,