X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fhash.c;fp=ccan%2Ftdb2%2Fhash.c;h=afa5b745717bdb234c84320ca8fed4358bd80973;hp=17601c0c8bf3fc2bf3ed2496735c3dc725e8e7fd;hb=b24f8e2ae5ac22fc2e5dbfebebf9c5fa2f338588;hpb=39b9d9ef8c05224b5f2685003160f4092fbd7045 diff --git a/ccan/tdb2/hash.c b/ccan/tdb2/hash.c index 17601c0c..afa5b745 100644 --- a/ccan/tdb2/hash.c +++ b/ccan/tdb2/hash.c @@ -678,7 +678,7 @@ again: } /* Return 1 if we find something, 0 if not, -1 on error. */ -int next_in_hash(struct tdb_context *tdb, int ltype, +int next_in_hash(struct tdb_context *tdb, struct traverse_info *tinfo, TDB_DATA *kbuf, size_t *dlen) { @@ -689,7 +689,7 @@ int next_in_hash(struct tdb_context *tdb, int ltype, hl_start = (tdb_off_t)tinfo->toplevel_group << (64 - group_bits); hl_range = 1ULL << group_bits; - if (tdb_lock_hashes(tdb, hl_start, hl_range, ltype, + if (tdb_lock_hashes(tdb, hl_start, hl_range, F_RDLCK, TDB_LOCK_WAIT) != 0) return -1; @@ -699,7 +699,7 @@ int next_in_hash(struct tdb_context *tdb, int ltype, if (tdb_read_convert(tdb, off, &rec, sizeof(rec))) { tdb_unlock_hashes(tdb, - hl_start, hl_range, ltype); + hl_start, hl_range, F_RDLCK); return -1; } if (rec_magic(&rec) != TDB_USED_MAGIC) { @@ -725,11 +725,11 @@ int next_in_hash(struct tdb_context *tdb, int ltype, off + sizeof(rec), kbuf->dsize); } - tdb_unlock_hashes(tdb, hl_start, hl_range, ltype); + tdb_unlock_hashes(tdb, hl_start, hl_range, F_RDLCK); return kbuf->dptr ? 1 : -1; } - tdb_unlock_hashes(tdb, hl_start, hl_range, ltype); + tdb_unlock_hashes(tdb, hl_start, hl_range, F_RDLCK); tinfo->toplevel_group++; tinfo->levels[0].hashtable @@ -740,7 +740,7 @@ int next_in_hash(struct tdb_context *tdb, int ltype, } /* Return 1 if we find something, 0 if not, -1 on error. */ -int first_in_hash(struct tdb_context *tdb, int ltype, +int first_in_hash(struct tdb_context *tdb, struct traverse_info *tinfo, TDB_DATA *kbuf, size_t *dlen) { @@ -751,7 +751,7 @@ int first_in_hash(struct tdb_context *tdb, int ltype, tinfo->levels[0].entry = 0; tinfo->levels[0].total_buckets = (1 << TDB_HASH_GROUP_BITS); - return next_in_hash(tdb, ltype, tinfo, kbuf, dlen); + return next_in_hash(tdb, tinfo, kbuf, dlen); } /* Even if the entry isn't in this hash bucket, you'd have to lock this