You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2013/08/07 15:49:45 UTC

svn commit: r1511313 - in /httpd/httpd/branches/2.4.x: ./ STATUS docs/manual/ docs/manual/howto/ docs/manual/mod/ docs/manual/rewrite/ modules/proxy/proxy_util.c

Author: jim
Date: Wed Aug  7 13:49:44 2013
New Revision: 1511313

URL: http://svn.apache.org/r1511313
Log:
Merge r1462269, r1463455 from trunk:

* Improve reusage of already resolved addresses to avoid unnecessary DNS lookups.

* Always try to reuse the address looked up for the worker if we are allowed to
  reuse the address. This saves DNS lookups.

Submitted by: rpluem
Reviewed/backported by: jim

Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/STATUS
    httpd/httpd/branches/2.4.x/docs/manual/   (props changed)
    httpd/httpd/branches/2.4.x/docs/manual/howto/   (props changed)
    httpd/httpd/branches/2.4.x/docs/manual/mod/   (props changed)
    httpd/httpd/branches/2.4.x/docs/manual/rewrite/   (props changed)
    httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1462269,1463455

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1511313&r1=1511312&r2=1511313&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Wed Aug  7 13:49:44 2013
@@ -92,11 +92,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * 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://people.apache.org/~jim/patches/proxy-dns-patch.txt
-    +1: jim, druggeri, rpluem
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:

Propchange: httpd/httpd/branches/2.4.x/docs/manual/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk/docs/manual:r1462269,1463455

Propchange: httpd/httpd/branches/2.4.x/docs/manual/howto/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk/docs/manual/howto:r1462269,1463455

Propchange: httpd/httpd/branches/2.4.x/docs/manual/mod/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk/docs/manual/mod:r1462269,1463455

Propchange: httpd/httpd/branches/2.4.x/docs/manual/rewrite/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk/docs/manual/rewrite:r1462269,1463455

Modified: httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c?rev=1511313&r1=1511312&r2=1511313&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c Wed Aug  7 13:49:44 2013
@@ -2132,34 +2132,46 @@ ap_proxy_determine_connection(apr_pool_t
             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_rerror(APLOG_MARK, APLOG_ERR, err, r, APLOGNO(00945) "lock");
-            return HTTP_INTERNAL_SERVER_ERROR;
+        if (!worker->s->is_address_reusable || worker->s->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->s->is_address_reusable && !worker->s->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_rerror(APLOG_MARK, APLOG_ERR, uerr, r, APLOGNO(00946) "unlock");
+        if (!worker->cp->addr) {
+            if ((err = PROXY_THREAD_LOCK(worker)) != APR_SUCCESS) {
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, err, r, APLOGNO(00945) "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_rerror(APLOG_MARK, APLOG_ERR, uerr, r, APLOGNO(00946) "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) {