From: Jim Jagielski Date: Tue, 11 Sep 2012 17:39:32 +0000 (+0000) Subject: Avoid the overhead of creating and grabbing a uuid for X-Git-Tag: 2.5.0-alpha~6344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=beba00de807a68e265273e58fd301b95dcca42eb;p=thirdparty%2Fapache%2Fhttpd.git Avoid the overhead of creating and grabbing a uuid for the balancer nonce if we're never going to use it. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1383490 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index fb085d0d019..e131489d287 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy_balancer: The nonce is only derived from the UUID iff + not set via the 'nonce' balancer param. [Jim Jagielski] + *) mod_lua: Add LuaInputFilter/LuaOutputFilter for creating content filters in Lua [Daniel Gruno] diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index a4fe6f25857..6030dbe027d 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1109,6 +1109,8 @@ PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p, return NULL; } +#define PROXY_UNSET_NONCE '\n' + PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p, proxy_balancer **balancer, proxy_server_conf *conf, @@ -1116,9 +1118,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p, const char *alias, int do_malloc) { - char nonce[APR_UUID_FORMATTED_LENGTH + 1]; proxy_balancer_method *lbmethod; - apr_uuid_t uuid; proxy_balancer_shared *bshared; char *c, *q, *uri = apr_pstrdup(p, url); const char *sname; @@ -1173,14 +1173,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p, (*balancer)->hash = bshared->hash; bshared->forcerecovery = 1; - - /* Retrieve a UUID and store the nonce for the lifetime of - * the process. */ - apr_uuid_get(&uuid); - apr_uuid_format(nonce, &uuid); - if (PROXY_STRNCPY(bshared->nonce, nonce) != APR_SUCCESS) { - return apr_psprintf(p, "balancer nonce (%s) too long", nonce); - } + *bshared->nonce = PROXY_UNSET_NONCE; /* impossible valid input */ (*balancer)->s = bshared; (*balancer)->sconf = conf; @@ -1195,6 +1188,7 @@ PROXY_DECLARE(apr_status_t) ap_proxy_share_balancer(proxy_balancer *balancer, proxy_balancer_shared *shm, int i) { + apr_status_t rv = APR_SUCCESS; proxy_balancer_method *lbmethod; if (!shm || !balancer->s) return APR_EINVAL; @@ -1208,7 +1202,18 @@ PROXY_DECLARE(apr_status_t) ap_proxy_share_balancer(proxy_balancer *balancer, lbmethod = ap_lookup_provider(PROXY_LBMETHOD, balancer->s->lbpname, "0"); if (lbmethod) balancer->lbmethod = lbmethod; - return APR_SUCCESS; + + if (*balancer->s->nonce == PROXY_UNSET_NONCE) { + char nonce[APR_UUID_FORMATTED_LENGTH + 1]; + apr_uuid_t uuid; + /* Retrieve a UUID and store the nonce for the lifetime of + * the process. + */ + apr_uuid_get(&uuid); + apr_uuid_format(nonce, &uuid); + rv = PROXY_STRNCPY(balancer->s->nonce, nonce); + } + return rv; } PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balancer, server_rec *s, apr_pool_t *p)