Commit f33ee6fe authored by Ruediger Pluem's avatar Ruediger Pluem
Browse files

* If CPING fails retry once more with a fresh TCP connection. If this fails

  as well give up.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@693392 13f79535-47bb-0310-9956-ffa450edef68
parent ea486ecd
Loading
Loading
Loading
Loading
+15 −4
Changes for modules/proxy/mod_proxy_ajp.c: 15 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -554,6 +554,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);

@@ -597,6 +598,8 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
    backend->is_ssl = 0;
    backend->close = 0;

    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,
@@ -604,7 +607,7 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
                                               sizeof(server_portstr));

        if (status != OK)
        goto cleanup;
            break;

        /* Step Two: Make the Connection */
        if (ap_proxy_connect_backend(scheme, backend, worker, r->server)) {
@@ -612,13 +615,19 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
                         "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,
@@ -626,14 +635,16 @@ static int proxy_ajp_handler(request_rec *r, proxy_worker *worker,
                             worker->cp->addr,
                             worker->hostname);
                status = HTTP_SERVICE_UNAVAILABLE;
            goto cleanup;
                retry++;
                continue;
            }
        }
        /* Step Three: Process the Request */
        status = ap_proxy_ajp_request(p, r, backend, origin, dconf, uri, url,
                                      server_portstr);
        break;
    }

cleanup:
    /* Do not close the socket */
    ap_proxy_release_connection(scheme, backend, r->server);
    return status;