httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1533087 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.h mod_proxy_balancer.c proxy_util.c
Date Thu, 17 Oct 2013 14:10:43 GMT
Author: jim
Date: Thu Oct 17 14:10:43 2013
New Revision: 1533087

URL: http://svn.apache.org/r1533087
Log:
Put the uds path in its own field, and adjust the logic
to look for an empty string rather than a flag.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1533087&r1=1533086&r2=1533087&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Thu Oct 17 14:10:43 2013
@@ -342,6 +342,7 @@ typedef struct {
     char      route[PROXY_WORKER_MAX_ROUTE_SIZE];     /* balancing route */
     char      redirect[PROXY_WORKER_MAX_ROUTE_SIZE];  /* temporary balancing redirection
route */
     char      flusher[PROXY_WORKER_MAX_SCHEME_SIZE];  /* flush provider used by mod_proxy_fdpass
*/
+    char      uds_path[PROXY_WORKER_MAX_NAME_SIZE];   /* path to worker's unix domain socket
if applicable */
     int             lbset;      /* load balancer cluster set */
     int             retries;    /* number of retries on this worker */
     int             lbstatus;   /* Current lbstatus */
@@ -388,7 +389,6 @@ typedef struct {
     unsigned int     keepalive_set:1;
     unsigned int     disablereuse_set:1;
     unsigned int     was_malloced:1;
-    unsigned int     uds:1;
 } proxy_worker_shared;
 
 #define ALIGNED_PROXY_WORKER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_worker_shared)))

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1533087&r1=1533086&r2=1533087&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Thu Oct 17 14:10:43 2013
@@ -1533,8 +1533,8 @@ static int balancer_handler(request_rec 
                           ap_escape_uri(r->pool, worker->s->name),
                           "&nonce=", balancer->s->nonce,
                           "\">", NULL);
-                ap_rvputs(r, (worker->s->uds ? "<i>" : ""), ap_proxy_worker_name(r->pool,
worker),
-                          (worker->s->uds ? "</i>" : ""), "</a></td>",
NULL);
+                ap_rvputs(r, (*worker->s->uds_path ? "<i>" : ""), ap_proxy_worker_name(r->pool,
worker),
+                          (*worker->s->uds_path ? "</i>" : ""), "</a></td>",
NULL);
                 ap_rvputs(r, "<td>", ap_escape_html(r->pool, worker->s->route),
                           NULL);
                 ap_rvputs(r, "</td><td>",
@@ -1559,7 +1559,7 @@ static int balancer_handler(request_rec 
         ap_rputs("<hr />\n", r);
         if (wsel && bsel) {
             ap_rputs("<h3>Edit worker settings for ", r);
-            ap_rvputs(r, (wsel->s->uds?"<i>":""), ap_proxy_worker_name(r->pool,
wsel), (wsel->s->uds?"</i>":""), "</h3>\n", NULL);
+            ap_rvputs(r, (*wsel->s->uds_path?"<i>":""), ap_proxy_worker_name(r->pool,
wsel), (*wsel->s->uds_path?"</i>":""), "</h3>\n", NULL);
             ap_rputs("<form method=\"POST\" enctype=\"application/x-www-form-urlencoded\"
action=\"", r);
             ap_rvputs(r, ap_escape_uri(r->pool, action), "\">\n", NULL);
             ap_rputs("<dl>\n<table><tr><td>Load factor:</td><td><input
name='w_lf' id='w_lf' type=text ", r);

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1533087&r1=1533086&r2=1533087&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Thu Oct 17 14:10:43 2013
@@ -1493,7 +1493,7 @@ PROXY_DECLARE(char *) ap_proxy_worker_na
     int rv;
     apr_uri_t uri;
     apr_pool_t *pool = p;
-    if (!worker->s->uds) {
+    if (!(*worker->s->uds_path)) {
         return worker->s->name;
     }
     if (!pool) {
@@ -1504,11 +1504,7 @@ PROXY_DECLARE(char *) ap_proxy_worker_na
             return worker->s->name;
         }
     }
-    rv = apr_uri_parse(pool, worker->s->name, &uri);
-    if (rv != APR_SUCCESS) {
-        return apr_pstrcat(pool, worker->s->name, "|", NULL);
-    }
-    return apr_pstrcat(pool, "unix:", uri.path, "|", uri.scheme, ":", NULL);
+    return apr_pstrcat(pool, "unix:", worker->s->uds_path, "|", worker->s->name,
NULL);
 }
 
 PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
@@ -1609,16 +1605,17 @@ PROXY_DECLARE(char *) ap_proxy_define_wo
     proxy_worker_shared *wshared;
     char *ptr, *sockpath = NULL;
 
-    /* Look to see if we are using UDS:
-       require format: unix:/path/foo/bar.sock|http:
-       This results in talking http to the socket at /path/foo/bar.sock
-    */
+    /*
+     * Look to see if we are using UDS:
+     * require format: unix:/path/foo/bar.sock|http://ignored/path2/
+     * This results in talking http to the socket at /path/foo/bar.sock
+     */
     ptr = ap_strchr((char *)url, '|');
     if (ptr) {
         *ptr = '\0';
         rv = apr_uri_parse(p, url, &urisock);
         if (rv == APR_SUCCESS && !strcasecmp(urisock.scheme, "unix")) {
-            sockpath = urisock.path;
+            sockpath = ap_runtime_dir_relative(p, urisock.path);;
             url = ptr+1;    /* so we get the scheme for the uds */
         }
         else {
@@ -1633,16 +1630,13 @@ PROXY_DECLARE(char *) ap_proxy_define_wo
     if (!uri.scheme) {
         return apr_pstrcat(p, "URL must be absolute!: ", url, NULL);
     }
-    /* allow for http:|sock:/path */
+    /* allow for unix:/path|http: */
     if (!uri.hostname && !sockpath) {
         return apr_pstrcat(p, "URL must be absolute!: ", url, NULL);;
     }
 
     if (sockpath) {
         uri.hostname = "localhost";
-        uri.path = ap_runtime_dir_relative(p, sockpath);
-        uri.query = NULL;
-        uri.fragment = NULL;
     }
     else {
         ap_str_tolower(uri.hostname);
@@ -1702,7 +1696,15 @@ PROXY_DECLARE(char *) ap_proxy_define_wo
     wshared->hash.def = ap_proxy_hashfunc(wshared->name, PROXY_HASHFUNC_DEFAULT);
     wshared->hash.fnv = ap_proxy_hashfunc(wshared->name, PROXY_HASHFUNC_FNV);
     wshared->was_malloced = (do_malloc != 0);
-    wshared->uds = (sockpath != NULL);
+    if (sockpath) {
+        if (PROXY_STRNCPY(wshared->uds_path, sockpath) != APR_SUCCESS) {
+            return apr_psprintf(p, "worker uds path (%s) too long", sockpath);
+        }
+
+    }
+    else {
+        *wshared->uds_path = '\0';
+    }
 
     (*worker)->hash = wshared->hash;
     (*worker)->context = NULL;
@@ -2087,12 +2089,9 @@ PROXY_DECLARE(int) ap_proxy_acquire_conn
     (*conn)->close  = 0;
     (*conn)->inreslist = 0;
 
-    if (worker->s->uds) {
+    if (*worker->s->uds_path) {
         if ((*conn)->uds_path == NULL) {
-            apr_uri_t puri;
-            if (apr_uri_parse(worker->cp->pool, worker->s->name, &puri) ==
APR_SUCCESS) {
-                (*conn)->uds_path = apr_pstrdup(worker->cp->pool, puri.path);
-            }
+            (*conn)->uds_path = apr_pstrdup(worker->cp->pool, worker->s->uds_path);
         }
         if ((*conn)->uds_path) {
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02545)
@@ -2100,9 +2099,10 @@ PROXY_DECLARE(int) ap_proxy_acquire_conn
                          proxy_function, (*conn)->uds_path);
         }
         else {
+            /* should never happen */
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02546)
-                         "%s: cannot parse for UDS (%s)",
-                         proxy_function, worker->s->name);
+                         "%s: cannot determine UDS (%s)",
+                         proxy_function, worker->s->uds_path);
 
         }
     }
@@ -2182,7 +2182,7 @@ ap_proxy_determine_connection(apr_pool_t
      *      spilling the cached addr from the worker.
      */
     if (!conn->hostname || !worker->s->is_address_reusable ||
-        worker->s->disablereuse || worker->s->uds) {
+        worker->s->disablereuse || *worker->s->uds_path) {
         if (proxyname) {
             conn->hostname = apr_pstrdup(conn->pool, proxyname);
             conn->port = proxyport;
@@ -2220,7 +2220,7 @@ ap_proxy_determine_connection(apr_pool_t
             conn->port = uri->port;
         }
         socket_cleanup(conn);
-        if (!worker->s->uds && worker->s->is_address_reusable &&
!worker->s->disablereuse) {
+        if (!(*worker->s->uds_path) && 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.
@@ -2231,7 +2231,7 @@ ap_proxy_determine_connection(apr_pool_t
                                         conn->pool);
         }
     }
-    if (!worker->s->uds && worker->s->is_address_reusable &&
!worker->s->disablereuse) {
+    if (!(*worker->s->uds_path) && worker->s->is_address_reusable &&
!worker->s->disablereuse) {
         /*
          * Looking up the backend address for the worker only makes sense if
          * we can reuse the address.



Mime
View raw message