You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2009/01/07 21:00:57 UTC

svn commit: r732451 - in /httpd/httpd/trunk: CHANGES server/mpm/prefork/prefork.c

Author: trawick
Date: Wed Jan  7 12:00:56 2009
New Revision: 732451

URL: http://svn.apache.org/viewvc?rev=732451&view=rev
Log:
prefork: Fix child process hang during graceful restart/stop in
configurations with multiple listening sockets.

PR: 42829
Submitted by: Joe Orton, with some tweaking and testing from me


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/server/mpm/prefork/prefork.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=732451&r1=732450&r2=732451&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Wed Jan  7 12:00:56 2009
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.2
 [ When backported to 2.2.x, remove entry from this file ]
 
+ *) prefork: Fix child process hang during graceful restart/stop in
+    configurations with multiple listening sockets.  PR 42829.  [Joe Orton,
+    Jeff Trawick]
+
  *) prefork: Log an error instead of segfaulting when child startup fails
     due to pollset creation failures.  PR 46467.  [Jeff Trawick]
 

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=732451&r1=732450&r2=732451&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Wed Jan  7 12:00:56 2009
@@ -544,20 +544,27 @@
                 apr_int32_t numdesc;
                 const apr_pollfd_t *pdesc;
 
-                /* timeout == -1 == wait forever */
-                status = apr_pollset_poll(pollset, -1, &numdesc, &pdesc);
+                /* check for termination first so we don't sleep for a while in
+                 * poll if already signalled
+                 */
+                if (one_process && shutdown_pending) {
+                    SAFE_ACCEPT(accept_mutex_off());
+                    return;
+                }
+                else if (die_now) {
+                    /* In graceful stop/restart; drop the mutex
+                     * and terminate the child. */
+                    SAFE_ACCEPT(accept_mutex_off());
+                    clean_child_exit(0);
+                }
+                /* timeout == 10 seconds to avoid a hang at graceful restart/stop
+                 * caused by the closing of sockets by the signal handler
+                 */
+                status = apr_pollset_poll(pollset, apr_time_from_sec(10), 
+                                          &numdesc, &pdesc);
                 if (status != APR_SUCCESS) {
-                    if (APR_STATUS_IS_EINTR(status)) {
-                        if (one_process && shutdown_pending) {
-                            SAFE_ACCEPT(accept_mutex_off());
-                            return;
-                        }
-                        else if (die_now) {
-                            /* In graceful stop/restart; drop the mutex
-                             * and terminate the child. */
-                            SAFE_ACCEPT(accept_mutex_off());
-                            clean_child_exit(0);
-                        }
+                    if (APR_STATUS_IS_TIMEUP(status) ||
+                        APR_STATUS_IS_EINTR(status)) {
                         continue;
                     }
                     /* Single Unix documents select as returning errnos