]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/tdb1_lock.c
tdb2: Make TDB1 use the same tdb_hash() wrapper as TDB2
[ccan] / ccan / tdb2 / tdb1_lock.c
index 6498b7136726bf6083e774315bd4455caf9dde9a..65fa1c123c5086b208448ee0dcb8487f1073d965 100644 (file)
@@ -392,25 +392,30 @@ int tdb1_unlockall_read(struct tdb1_context *tdb)
    contention - it cannot guarantee how many records will be locked */
 int tdb1_chainlock(struct tdb1_context *tdb, TDB_DATA key)
 {
-       int ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK);
+       int ret = tdb1_lock(tdb,
+                           TDB1_BUCKET(tdb_hash(tdb, key.dptr, key.dsize)),
+                           F_WRLCK);
        return ret;
 }
 
 int tdb1_chainunlock(struct tdb1_context *tdb, TDB_DATA key)
 {
-       return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK);
+       return tdb1_unlock(tdb, TDB1_BUCKET(tdb_hash(tdb, key.dptr, key.dsize)),
+                          F_WRLCK);
 }
 
 int tdb1_chainlock_read(struct tdb1_context *tdb, TDB_DATA key)
 {
        int ret;
-       ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK);
+       ret = tdb1_lock(tdb, TDB1_BUCKET(tdb_hash(tdb, key.dptr, key.dsize)),
+                       F_RDLCK);
        return ret;
 }
 
 int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB_DATA key)
 {
-       return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK);
+       return tdb1_unlock(tdb, TDB1_BUCKET(tdb_hash(tdb, key.dptr, key.dsize)),
+                          F_RDLCK);
 }
 
 /* record lock stops delete underneath */