]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Avoid the overhead of creating and grabbing a uuid for
authorJim Jagielski <jim@apache.org>
Tue, 11 Sep 2012 17:39:32 +0000 (17:39 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 11 Sep 2012 17:39:32 +0000 (17:39 +0000)
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

CHANGES
modules/proxy/proxy_util.c

diff --git a/CHANGES b/CHANGES
index fb085d0d0194653797d5d428a4fce76db9c487f3..e131489d28794f3e54bffc77287e0e2f7c6c318e 100644 (file)
--- 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]
 
index a4fe6f258570eb8153bd73f4dc016481f834a551..6030dbe027d44055de2ba10506cf543252b51ea6 100644 (file)
@@ -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)