]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r693392 from trunk:
authorJim Jagielski <jim@apache.org>
Wed, 17 Sep 2008 14:32:37 +0000 (14:32 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 17 Sep 2008 14:32:37 +0000 (14:32 +0000)
* If CPING fails retry once more with a fresh TCP connection. If this fails
  as well give up.

Submitted by: rpluem
Reviewed by: jim

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

STATUS
modules/proxy/mod_proxy_ajp.c

diff --git a/STATUS b/STATUS
index a2fbb5bad5425d4a6b496abecbff65e0f07b478f..373ffc1a4b0cc8422f5c715a1e97ee5a5a2c42ba 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -102,13 +102,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
        http://people.apache.org/~covener/2.2.x-auth_alias_digest.diff 
    +1: covener, rpluem, jerenkrantz
 
- * mod_proxy_ajp: If CPING fails retry once more with a fresh TCP connection.
-   If this fails as well give up.
-   Trunk version of patches:
-      http://svn.apache.org/viewvc?rev=693392&view=rev
-   Backport version for 2.2.x of patch:
-       Trunk version of patches works
-   +1: rpluem, covener, jerenkrantz
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 80a6e0ab88e529cd564a26a8bdc683dbaeb792f1..7d27abefb17444b4dc0c67cb4230535f7b84aa36 100644 (file)
@@ -550,6 +550,7 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
     conn_rec *origin = NULL;
     proxy_conn_rec *backend = NULL;
     const char *scheme = "AJP";
+    int retry;
     proxy_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
                                                  &proxy_module);
 
@@ -595,43 +596,53 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
     backend->is_ssl = 0;
     backend->close_on_recycle = 0;
 
-    /* Step One: Determine Who To Connect To */
-    status = ap_proxy_determine_connection(p, r, conf, worker, backend,
-                                           uri, &url, proxyname, proxyport,
-                                           server_portstr,
-                                           sizeof(server_portstr));
-
-    if (status != OK)
-        goto cleanup;
-
-    /* Step Two: Make the Connection */
-    if (ap_proxy_connect_backend(scheme, backend, worker, r->server)) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
-                     "proxy: AJP: failed to make connection to backend: %s",
-                     backend->hostname);
-        status = HTTP_SERVICE_UNAVAILABLE;
-        goto cleanup;
-    }
+    retry = 0;
+    while (retry < 2) {
+        /* Step One: Determine Who To Connect To */
+        status = ap_proxy_determine_connection(p, r, conf, worker, backend,
+                                               uri, &url, proxyname, proxyport,
+                                               server_portstr,
+                                               sizeof(server_portstr));
 
-    /* Handle CPING/CPONG */
-    if (worker->ping_timeout_set) {
-        status = ajp_handle_cping_cpong(backend->sock, r,
-                                        worker->ping_timeout);
-        if (status != APR_SUCCESS) {
-            backend->close++;
-            ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
-                         "proxy: AJP: cping/cpong failed to %pI (%s)",
-                         worker->cp->addr,
-                         worker->hostname);
+        if (status != OK)
+            break;
+
+        /* Step Two: Make the Connection */
+        if (ap_proxy_connect_backend(scheme, backend, worker, r->server)) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+                         "proxy: AJP: failed to make connection to backend: %s",
+                         backend->hostname);
             status = HTTP_SERVICE_UNAVAILABLE;
-            goto cleanup;
+            break;
+        }
+
+        /* Handle CPING/CPONG */
+        if (worker->ping_timeout_set) {
+            status = ajp_handle_cping_cpong(backend->sock, r,
+                                            worker->ping_timeout);
+            /*
+             * In case the CPING / CPONG failed for the first time we might be
+             * just out of luck and got a faulty backend connection, but the
+             * backend might be healthy nevertheless. So ensure that the backend
+             * TCP connection gets closed and try it once again.
+             */
+            if (status != APR_SUCCESS) {
+                backend->close++;
+                ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
+                             "proxy: AJP: cping/cpong failed to %pI (%s)",
+                             worker->cp->addr,
+                             worker->hostname);
+                status = HTTP_SERVICE_UNAVAILABLE;
+                retry++;
+                continue;
+            }
         }
+        /* Step Three: Process the Request */
+        status = ap_proxy_ajp_request(p, r, backend, origin, dconf, uri, url,
+                                      server_portstr);
+        break;
     }
-    /* Step Three: Process the Request */
-    status = ap_proxy_ajp_request(p, r, backend, origin, dconf, uri, url,
-                                  server_portstr);
 
-cleanup:
     /* Do not close the socket */
     ap_proxy_release_connection(scheme, backend, r->server);
     return status;