]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy: save DNS lookups
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Jun 2016 17:29:41 +0000 (17:29 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 30 Jun 2016 17:29:41 +0000 (17:29 +0000)
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

STATUS
modules/proxy/proxy_util.c

diff --git a/STATUS b/STATUS
index b9861d2519af70e331b063a8e8a9626dfcecdce3..e5d14e7bf19c958c2d7275f3d7d1c1af00f038f3 100644 (file)
--- 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 ]
index 700d4589c41e80f69a5d66c2389371578fd96313..66bc42be1f4924d3143888aff8ee4767c51cba43 100644 (file)
@@ -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) {