httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r998949 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.h proxy_util.c
Date Mon, 20 Sep 2010 14:51:20 GMT
Author: jim
Date: Mon Sep 20 14:51:19 2010
New Revision: 998949

URL: http://svn.apache.org/viewvc?rev=998949&view=rev
Log:
Fold in possible use of FNV if desired

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    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=998949&r1=998948&r2=998949&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Mon Sep 20 14:51:19 2010
@@ -810,7 +810,7 @@ ap_proxy_buckets_lifetime_transform(requ
  * @return        hash as unsigned int
  */
 
-typedef enum { PROXY_HASHFUNC_PROXY, PROXY_HASHFUNC_APR } proxy_hash_t;
+typedef enum { PROXY_HASHFUNC_DEFAULT, PROXY_HASHFUNC_APR,  PROXY_HASHFUNC_FNV } proxy_hash_t;
 
 PROXY_DECLARE(unsigned int)
 ap_proxy_hashfunc(const char *str, proxy_hash_t method);

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=998949&r1=998948&r2=998949&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Mon Sep 20 14:51:19 2010
@@ -1481,7 +1481,7 @@ PROXY_DECLARE(const char *) ap_proxy_add
     (*worker)->flush_packets = flush_off;
     (*worker)->flush_wait = PROXY_FLUSH_WAIT;
     (*worker)->smax = -1;
-    (*worker)->our_hash = ap_proxy_hashfunc((*worker)->name, PROXY_HASHFUNC_PROXY);
+    (*worker)->our_hash = ap_proxy_hashfunc((*worker)->name, PROXY_HASHFUNC_DEFAULT);
     (*worker)->apr_hash = ap_proxy_hashfunc((*worker)->name, PROXY_HASHFUNC_APR);
     (*worker)->cp = NULL;
     (*worker)->mutex = NULL;
@@ -2766,10 +2766,10 @@ ap_proxy_buckets_lifetime_transform(requ
 
 /*
  * Provide a string hashing function for the proxy.
- * We offer 2 method: one is the APR model but we
- * also provide our own, based on SDBM. The reason
- * is in case we want to use both to ensure no
- * collisions
+ * We offer 2 methods: one is the APR model but we
+ * also provide our own, based on either FNV or SDBM.
+ * The reason is in case we want to use both to ensure no
+ * collisions.
  */
 PROXY_DECLARE(unsigned int)
 ap_proxy_hashfunc(const char *str, proxy_hash_t method)
@@ -2777,13 +2777,21 @@ ap_proxy_hashfunc(const char *str, proxy
     if (method == PROXY_HASHFUNC_APR) {
         apr_ssize_t slen = strlen(str);
         return apr_hashfunc_default(str, &slen);
-    } else {
+    } else if (method == PROXY_HASHFUNC_FNV) {
+        /* FNV model */
+        unsigned int hash;
+        const unsigned int fnv_prime = 0x811C9DC5;
+        for (hash = 0; *str; str++) {
+            hash *= fnv_prime;
+            hash ^= (*str);
+        }
+        return hash;
+    } else { /* method == PROXY_HASHFUNC_DEFAULT */
         /* SDBM model */
         unsigned int hash;
-        for(hash = 0; *str; str++) {
+        for (hash = 0; *str; str++) {
             hash = (*str) + (hash << 6) + (hash << 16) - hash;
         }
         return hash;
     }
-    
 }



Mime
View raw message