httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1208068 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy.h proxy_util.c
Date Tue, 29 Nov 2011 21:14:09 GMT
Author: jim
Date: Tue Nov 29 21:14:08 2011
New Revision: 1208068

URL: http://svn.apache.org/viewvc?rev=1208068&view=rev
Log:
Some optimization... we have a hash, use it. Quicker than all
these string comparisons.

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

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1208068&r1=1208067&r2=1208068&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Nov 29 21:14:08 2011
@@ -1464,6 +1464,7 @@ static const char *
             if (err)
                 return apr_pstrcat(cmd->temp_pool, "ProxyPass ", err, NULL);
         }
+        new->balancer = balancer;
     }
     else {
         proxy_worker *worker = ap_proxy_get_worker(cmd->temp_pool, NULL, conf, r);

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1208068&r1=1208067&r2=1208068&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Nov 29 21:14:08 2011
@@ -88,6 +88,11 @@ enum enctype {
  */
 #define DEFAULT_MAX_FORWARDS    -1
 
+typedef struct proxy_balancer  proxy_balancer;
+typedef struct proxy_worker    proxy_worker;
+typedef struct proxy_conn_pool proxy_conn_pool;
+typedef struct proxy_balancer_method proxy_balancer_method;
+
 /* static information about a remote proxy */
 struct proxy_remote {
     const char *scheme;     /* the schemes handled by this proxy, or '*' */
@@ -105,6 +110,7 @@ struct proxy_alias {
     const char  *fake;
     ap_regex_t  *regex;
     unsigned int flags;
+    proxy_balancer *balancer; /* only valid for reverse-proxys */
 };
 
 struct dirconn_entry {
@@ -119,11 +125,6 @@ struct noproxy_entry {
     struct apr_sockaddr_t *addr;
 };
 
-typedef struct proxy_balancer  proxy_balancer;
-typedef struct proxy_worker    proxy_worker;
-typedef struct proxy_conn_pool proxy_conn_pool;
-typedef struct proxy_balancer_method proxy_balancer_method;
-
 typedef struct {
     apr_array_header_t *proxies;
     apr_array_header_t *sec_proxy;
@@ -408,7 +409,7 @@ typedef struct {
     apr_time_t      wupdated;     /* timestamp of last change to workers list */
     int             max_attempts;     /* Number of attempts before failing */
     int             index;      /* shm array index */
-    int hash;
+    unsigned int hash;
     unsigned int    sticky_force:1;   /* Disable failover for sticky sessions */
     unsigned int    scolonsep:1;      /* true if ';' seps sticky session paths */
     unsigned int    max_attempts_set:1;
@@ -427,7 +428,7 @@ struct proxy_balancer {
     ap_slotmem_provider_t *storage;
     int growth;                   /* number of post-config workers can added */
     int max_workers;              /* maximum number of allowed workers */
-    int hash;
+    unsigned int hash;
     apr_time_t      wupdated;    /* timestamp of last change to workers list */
     proxy_balancer_method *lbmethod;
     apr_global_mutex_t  *gmutex; /* global lock for updating list of workers */

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1208068&r1=1208067&r2=1208068&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Tue Nov 29 21:14:08 2011
@@ -1298,6 +1298,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy
     proxy_balancer *balancer;
     char *c, *uri = apr_pstrdup(p, url);
     int i;
+    unsigned int hash;
 
     c = strchr(uri, ':');
     if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
@@ -1307,9 +1308,10 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy
     if ((c = strchr(c + 3, '/'))) {
         *c = '\0';
     }
+    hash = ap_proxy_hashfunc(uri, PROXY_HASHFUNC_DEFAULT);
     balancer = (proxy_balancer *)conf->balancers->elts;
     for (i = 0; i < conf->balancers->nelts; i++) {
-        if (strcasecmp(balancer->s->name, uri) == 0) {
+        if (balancer->hash == hash) {
             if (!care || !balancer->s->inactive) {
                 return balancer;
             }
@@ -1410,6 +1412,7 @@ PROXY_DECLARE(char *) ap_proxy_define_ba
     }
 
     (*balancer)->s = bshared;
+    (*balancer)->sconf = conf;
 
     return ap_proxy_update_balancer(p, *balancer, alias);
 }



Mime
View raw message