From: William A. Rowe Jr Date: Thu, 30 Jun 2016 17:29:41 +0000 (+0000) Subject: mod_proxy: save DNS lookups X-Git-Tag: 2.2.32~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e23653e34eeb6b16176a846d49068c42618c2888;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy: save DNS lookups Backports: r1462269, r1463455 Submitted by: rpluem Reviewed by: wrowe, ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1750843 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index b9861d2519a..e5d14e7bf19 100644 --- a/STATUS +++ b/STATUS @@ -112,13 +112,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: http://people.apache.org/~rpluem/patches/proxy_race_retry_2.2.x_v2.diff +1: rpluem, wrowe, ylavic - *) mod_proxy: save DNS lookups - trunk patch: https://svn.apache.org/viewvc?view=revision&revision=1462269 - https://svn.apache.org/viewvc?view=revision&revision=1463455 - 2.4.x patch: http://svn.apache.org/viewvc?view=revision&revision=1511313 - 2.2.x patch: http://people.apache.org/~rpluem/patches/proxy-dns-patch_2.2.x.diff - +1: rpluem, wrowe, ylavic - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 700d4589c41..66bc42be1f4 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2233,36 +2233,48 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, conn->port = uri->port; } socket_cleanup(conn); - err = apr_sockaddr_info_get(&(conn->addr), - conn->hostname, APR_UNSPEC, - conn->port, 0, - conn->pool); - } - else if (!worker->cp->addr) { - if ((err = PROXY_THREAD_LOCK(worker)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, - "proxy: lock"); - return HTTP_INTERNAL_SERVER_ERROR; + if (!worker->is_address_reusable || worker->disablereuse) { + /* + * Only do a lookup if we should not reuse the backend address. + * Otherwise we will look it up once for the worker. + */ + err = apr_sockaddr_info_get(&(conn->addr), + conn->hostname, APR_UNSPEC, + conn->port, 0, + conn->pool); } - + } + if (worker->is_address_reusable && !worker->disablereuse) { /* - * Worker can have the single constant backend adress. - * The single DNS lookup is used once per worker. - * If dynamic change is needed then set the addr to NULL - * inside dynamic config to force the lookup. + * Looking up the backend address for the worker only makes sense if + * we can reuse the address. */ - err = apr_sockaddr_info_get(&(worker->cp->addr), - conn->hostname, APR_UNSPEC, - conn->port, 0, - worker->cp->pool); - conn->addr = worker->cp->addr; - if ((uerr = PROXY_THREAD_UNLOCK(worker)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, uerr, r->server, - "proxy: unlock"); + if (!worker->cp->addr) { + if ((err = PROXY_THREAD_LOCK(worker)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, + "proxy: lock"); + return HTTP_INTERNAL_SERVER_ERROR; + } + + /* + * Worker can have the single constant backend adress. + * The single DNS lookup is used once per worker. + * If dynamic change is needed then set the addr to NULL + * inside dynamic config to force the lookup. + */ + err = apr_sockaddr_info_get(&(worker->cp->addr), + conn->hostname, APR_UNSPEC, + conn->port, 0, + worker->cp->pool); + conn->addr = worker->cp->addr; + if ((uerr = PROXY_THREAD_UNLOCK(worker)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, uerr, r->server, + "proxy: unlock"); + } + } + else { + conn->addr = worker->cp->addr; } - } - else { - conn->addr = worker->cp->addr; } /* Close a possible existing socket if we are told to do so */ if (conn->close) {