]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1667385 from trunk:
authorJim Jagielski <jim@apache.org>
Fri, 27 Mar 2015 12:24:02 +0000 (12:24 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 27 Mar 2015 12:24:02 +0000 (12:24 +0000)
Retry ENOENT like ECONNREFUSED, but only near a server restart.

PR57685

Submitted By: Edward Lu
Committed By: covener

Submitted by: covener
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1669559 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/generators/mod_cgid.c

diff --git a/CHANGES b/CHANGES
index 9f542063d6b78eadf99dca865ae6dd8f583f1c08..161ae68f9d626f330a5c01032fc8138a79b9d2f1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,12 @@ Changes with Apache 2.4.13
      calls r:wsupgrade() can cause a child process crash. 
      [Edward Lu <Chaosed0 gmail.com>]
 
+  *) mod_cgid: Within the first minute of a server start or restart, 
+     allow mod_cgid to retry connecting to its daemon process. Previously,
+     'No such file or directory: unable to connect to cgi daemon...' could
+     be logged without an actual retry. PR57685. 
+     [Edward Lu <Chaosed0 gmail.com>]
+     
   *) mod_proxy: use the original (non absolute) form of the request-line's URI
      for requests embedded in CONNECT payloads used to connect SSL backends via
      a ProxyRemote forward-proxy.  PR 55892.  [Hendrik Harms <hendrik.harms
diff --git a/STATUS b/STATUS
index 610af2d0ced6b929c5c3b6f4c5fe2e00ef2b97e1..bbe84d43dded147eb99501731611ddfeb1f7aad2 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -106,28 +106,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_proxy: use the original (non absolute) form of the request-line's URI
-     for requests embedded in CONNECT payloads used to connect SSL backends via
-     a ProxyRemote forward-proxy. PR 55892.
-     trunk patch: http://svn.apache.org/r1665215
-                  http://svn.apache.org/r1665218 (CHANGES entry)
-     2.4.x patch: trunk works (modulo CHANGES)
-     +1: ylavic, wrowe, jim
-
-  *) mod_proxy_http: Don't expect the backend to ack the "Connection: close" to
-     finally close those not meant to be kept alive by SetEnv proxy-nokeepalive
-     or force-proxy-request-1.0.
-     trunk patch: http://svn.apache.org/r1658760 (partial, ap_proxy_clear_connection() raises no error in 2.4.x)
-     2.4.x patch: http://people.apache.org/~ylavic/httpd-2.4.x-mod_proxy_http-nokeepalive_close.patch
-     +1: ylavic, covener, jim
-
-  *) mod_cgid: When the request thread can't contact the CGID daemon, 
-               Handle ENOENT during the startup/restart with the same delay
-               used for ECONNREFUSED. PR57685
-     trunk patch: http://svn.apache.org/r1667385 
-     2.4.x patch: trunk works
-     +1: covener, ylavic, jim
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 26022d8498869596d3aba8f49afc0ce6a74b77ec..b5f0bebf5de76833561a959f4a973faa317d2f37 100644 (file)
@@ -170,6 +170,10 @@ static int is_scriptaliased(request_rec *r)
 #define DEFAULT_CONNECT_ATTEMPTS  15
 #endif
 
+#ifndef DEFAULT_CONNECT_STARTUP_DELAY
+#define DEFAULT_CONNECT_STARTUP_DELAY 60
+#endif
+
 typedef struct {
     const char *logname;
     long logbytes;
@@ -1203,18 +1207,26 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
 {
     int sd;
     int connect_tries;
+    int connect_errno;
     apr_interval_time_t sliding_timer;
 
     connect_tries = 0;
     sliding_timer = 100000; /* 100 milliseconds */
     while (1) {
+        connect_errno = 0;
         ++connect_tries;
         if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
             return log_scripterror(r, conf, HTTP_INTERNAL_SERVER_ERROR, errno,
                                    APLOGNO(01255) "unable to create socket to cgi daemon");
         }
         if (connect(sd, (struct sockaddr *)server_addr, server_addr_len) < 0) {
-            if (errno == ECONNREFUSED && connect_tries < DEFAULT_CONNECT_ATTEMPTS) {
+            /* Save errno for later */
+            connect_errno = errno;
+            /* ECONNREFUSED means the listen queue is full; ENOENT means that
+             * the cgid server either hasn't started up yet, or we're pointing
+             * at the wrong socket file */
+            if ((errno == ECONNREFUSED || errno == ENOENT) && 
+                 connect_tries < DEFAULT_CONNECT_ATTEMPTS) {
                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, APLOGNO(01256)
                               "connect #%d to cgi daemon failed, sleeping before retry",
                               connect_tries);
@@ -1235,9 +1247,20 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
                                       close_unix_socket, apr_pool_cleanup_null);
             break; /* we got connected! */
         }
+
+        /* If we didn't find the socket but the server was not recently restarted,
+         * chances are there's something wrong with the cgid daemon
+         */
+        if (connect_errno == ENOENT &&
+            apr_time_sec(apr_time_now() - ap_scoreboard_image->global->restart_time) > 
+                DEFAULT_CONNECT_STARTUP_DELAY) {
+            return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, connect_errno, 
+                                   apr_pstrcat(r->pool, APLOGNO(02831) "ScriptSock ", sockname, " does not exist", NULL));
+        }
+
         /* gotta try again, but make sure the cgid daemon is still around */
-        if (kill(daemon_pid, 0) != 0) {
-            return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO(01258)
+        if (connect_errno != ENOENT && kill(daemon_pid, 0) != 0) {
+            return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, connect_errno, APLOGNO(01258)
                                    "cgid daemon is gone; is Apache terminating?");
         }
     }