TODO lib/tdb: use jenkins_hash for non persistent tdbs
authorStefan Metzmacher <metze@samba.org>
Fri, 10 Sep 2010 04:40:03 +0000 (06:40 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Apr 2011 15:59:21 +0000 (17:59 +0200)
metze

lib/tdb/common/open.c

index ff0fd376017b5c3db6764b4d2ade71d65814f384..97fd5b1cc2f034e0ceefb08db144dc34847edafc 100644 (file)
@@ -44,6 +44,10 @@ static unsigned int default_tdb_hash(TDB_DATA *key)
        return (1103515243 * value + 12345);  
 }
 
+static unsigned int jenkins_hash(TDB_DATA *key)
+{
+       return hash_any(key->dptr, key->dsize, 0);
+}
 
 /* initialise a new database with a specified hash size */
 static int tdb_new_database(struct tdb_context *tdb, int hash_size)
@@ -190,8 +194,13 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
                tdb->hash_fn = hash_fn;
                hash_alg = "user_defined";
        } else {
-               tdb->hash_fn = default_tdb_hash;
-               hash_alg = "default";
+               if (tdb_flags & TDB_CLEAR_IF_FIRST) {
+                       tdb->hash_fn = jenkins_hash;
+                       hash_alg = "jenkins";
+               } else {
+                       tdb->hash_fn = default_tdb_hash;
+                       hash_alg = "default";
+               }
        }
 
        /* cache the page size */