Commit d2a743d4 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Some optimization... we have a hash, use it. Quicker than all

these string comparisons.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1208068 13f79535-47bb-0310-9956-ffa450edef68
parent 3f7c421c
Loading
Loading
Loading
Loading
+1 −0
Changes for modules/proxy/mod_proxy.c: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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);
+8 −7
Changes for modules/proxy/mod_proxy.h: 8 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -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 */
+4 −1
Changes for modules/proxy/proxy_util.c: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1298,6 +1298,7 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
    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_get_balancer(apr_pool_t *p,
    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_balancer(apr_pool_t *p,
    }

    (*balancer)->s = bshared;
    (*balancer)->sconf = conf;

    return ap_proxy_update_balancer(p, *balancer, alias);
}