arrfab / rpms / httpd

Forked from rpms/httpd 5 years ago
Clone

Blame SOURCES/httpd-2.4.6-r1348019.patch

cce4bc
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
cce4bc
index 2121892..6f904b2 100644
cce4bc
--- a/modules/proxy/proxy_util.c
cce4bc
+++ b/modules/proxy/proxy_util.c
cce4bc
@@ -2838,33 +2838,48 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
cce4bc
 
cce4bc
         connected    = 1;
cce4bc
     }
cce4bc
-    /*
cce4bc
-     * Put the entire worker to error state if
cce4bc
-     * the PROXY_WORKER_IGNORE_ERRORS flag is not set.
cce4bc
-     * Altrough some connections may be alive
cce4bc
-     * no further connections to the worker could be made
cce4bc
-     */
cce4bc
-    if (!connected && PROXY_WORKER_IS_USABLE(worker) &&
cce4bc
-        !(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) {
cce4bc
-        worker->s->error_time = apr_time_now();
cce4bc
-        worker->s->status |= PROXY_WORKER_IN_ERROR;
cce4bc
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00959)
cce4bc
-            "ap_proxy_connect_backend disabling worker for (%s) for %"
cce4bc
-            APR_TIME_T_FMT "s",
cce4bc
-            worker->s->hostname, apr_time_sec(worker->s->retry));
cce4bc
+
cce4bc
+    if (PROXY_WORKER_IS_USABLE(worker)) {
cce4bc
+        /*
cce4bc
+         * Put the entire worker to error state if
cce4bc
+         * the PROXY_WORKER_IGNORE_ERRORS flag is not set.
cce4bc
+         * Although some connections may be alive
cce4bc
+         * no further connections to the worker could be made
cce4bc
+         */
cce4bc
+        if (!connected) {
cce4bc
+            if (!(worker->s->status & PROXY_WORKER_IGNORE_ERRORS)) {
cce4bc
+                worker->s->error_time = apr_time_now();
cce4bc
+                worker->s->status |= PROXY_WORKER_IN_ERROR;
cce4bc
+                ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00959)
cce4bc
+                    "ap_proxy_connect_backend disabling worker for (%s) for %"
cce4bc
+                    APR_TIME_T_FMT "s",
cce4bc
+                    worker->s->hostname, apr_time_sec(worker->s->retry));
cce4bc
+            }
cce4bc
+        }
cce4bc
+        else {
cce4bc
+            if (worker->s->retries) {
cce4bc
+                /*
cce4bc
+                 * A worker came back. So here is where we need to
cce4bc
+                 * either reset all params to initial conditions or
cce4bc
+                 * apply some sort of aging
cce4bc
+                 */
cce4bc
+            }
cce4bc
+            worker->s->error_time = 0;
cce4bc
+            worker->s->retries = 0;
cce4bc
+        }
cce4bc
+        return connected ? OK : DECLINED;
cce4bc
     }
cce4bc
     else {
cce4bc
-        if (worker->s->retries) {
cce4bc
-            /*
cce4bc
-             * A worker came back. So here is where we need to
cce4bc
-             * either reset all params to initial conditions or
cce4bc
-             * apply some sort of aging
cce4bc
-             */
cce4bc
-        }
cce4bc
-        worker->s->error_time = 0;
cce4bc
-        worker->s->retries = 0;
cce4bc
+        /*
cce4bc
+         * The worker is in error likely done by a different thread / process
cce4bc
+         * e.g. for a timeout or bad status. We should respect this and should
cce4bc
+         * not continue with a connection via this worker even if we got one.
cce4bc
+         */
cce4bc
+         if (connected) {
cce4bc
+             socket_cleanup(conn);
cce4bc
+         }
cce4bc
+         return DECLINED;
cce4bc
     }
cce4bc
-    return connected ? OK : DECLINED;
cce4bc
 }
cce4bc
 
cce4bc
 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,