]> granicus.if.org Git - apache/commitdiff
Fix an issue with the pod and prefork:
authorJeff Trawick <trawick@apache.org>
Wed, 11 Jul 2001 14:48:23 +0000 (14:48 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 11 Jul 2001 14:48:23 +0000 (14:48 +0000)
when the parent process wakes up a server process via connect(), use
an APR timeout on the connect() so that we don't hang for a long time
if there aren't server processes around to do accept()

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89539 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/mpm_common.c

diff --git a/CHANGES b/CHANGES
index d00f48322597f8274fe28745b8d7dbbdeefad324..05fd7941b8c1b15fed9b94e88927471a92b721d0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,13 @@
 Changes with Apache 2.0.21-dev
+
+  *) Fix some issues with the pod and prefork: check the pod *after*
+     processing a connection so that a server processing a time-
+     consuming request bails out as soon as practical; when the
+     parent process wakes up a server process via connect(), use an
+     APR timeout on the connect() so that we don't hang for a long
+     time if there aren't server processes around to do accept().
+     [Jeff Trawick, Greg Ames]
+
   *) Performance improvement to mod_mime.c. find_ct() in mod_mime, 
      spends a lot of time in apr_table_get calls.  Using the default 
      httpd.conf, the tables for languages and charsets are somewhat
index 7cd94063c223cd73467f9b3ff0a33dbc7e68a0a1..006d813341d959361a8b21b6d41dc70b1c9a9b93 100644 (file)
@@ -409,9 +409,31 @@ AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod)
                      "get socket to connect to listener");
         return rv;
     }
-    rv = apr_connect(sock, sa);    
+    /* on some platforms (e.g., FreeBSD), the kernel won't accept many
+     * queued connections before it starts blocking local connects...
+     * we need to keep from blocking too long and instead return an error,
+     * because the MPM won't want to hold up a graceful restart for a
+     * long time
+     */
+    rv = apr_setsocketopt(sock, APR_SO_TIMEOUT, 3 * APR_USEC_PER_SEC);
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf,
+                     "set timeout on socket to connect to listener");
+        return rv;
+    }
+    rv = apr_connect(sock, sa);    
+    if (rv != APR_SUCCESS) {
+        int log_level = APLOG_WARNING;
+
+        if (APR_STATUS_IS_TIMEUP(rv)) {
+            /* probably some server processes bailed out already and there 
+             * is nobody around to call accept and clear out the kernel 
+             * connection queue; usually this is not worth logging
+             */
+            log_level = APLOG_DEBUG;
+        }
+       
+        ap_log_error(APLOG_MARK, log_level, rv, ap_server_conf,
                      "connect to listener");
         return rv;
     }
@@ -423,8 +445,10 @@ AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod)
 AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num)
 {
     int i;
-    for (i = 0; i < num; i++) {
-        ap_mpm_pod_signal(pod);
+    apr_status_t rv = APR_SUCCESS;
+
+    for (i = 0; i < num && rv == APR_SUCCESS; i++) {
+        rv = ap_mpm_pod_signal(pod);
     }
 }
 #endif