X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=inline;f=ccan%2Ftdb2%2Flock.c;h=8e73c253cb5ba4eac0ba9cc3c54fbe62ecbc9132;hb=6892edd66e0a1f2f8633c59b8cf8d0fa91e82394;hp=98570d7627e7a38272c4f72ebcf60edece5dadfd;hpb=1ad66fedf81fdaf0f07a2b00d6787614c58a23ef;p=ccan diff --git a/ccan/tdb2/lock.c b/ccan/tdb2/lock.c index 98570d76..8e73c253 100644 --- a/ccan/tdb2/lock.c +++ b/ccan/tdb2/lock.c @@ -236,8 +236,7 @@ enum TDB_ERROR tdb_allrecord_upgrade(struct tdb_context *tdb) "tdb_allrecord_upgrade failed"); } -static struct tdb_lock_type *find_nestlock(struct tdb_context *tdb, - tdb_off_t offset) +static struct tdb_lock *find_nestlock(struct tdb_context *tdb, tdb_off_t offset) { unsigned int i; @@ -276,10 +275,11 @@ static enum TDB_ERROR tdb_nest_lock(struct tdb_context *tdb, tdb_off_t offset, int ltype, enum tdb_lock_flags flags) { - struct tdb_lock_type *new_lck; + struct tdb_lock *new_lck; enum TDB_ERROR ecode; - if (offset > TDB_HASH_LOCK_START + TDB_HASH_LOCK_RANGE + tdb->map_size / 8) { + if (offset > (TDB_HASH_LOCK_START + TDB_HASH_LOCK_RANGE + + tdb->file->map_size / 8)) { return tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR, "tdb_nest_lock: invalid offset %zu ltype=%d", (size_t)offset, ltype); @@ -310,7 +310,7 @@ static enum TDB_ERROR tdb_nest_lock(struct tdb_context *tdb, "tdb_nest_lock: already have a hash lock?"); } - new_lck = (struct tdb_lock_type *)realloc( + new_lck = (struct tdb_lock *)realloc( tdb->file->lockrecs, sizeof(*tdb->file->lockrecs) * (tdb->file->num_lockrecs+1)); if (new_lck == NULL) { @@ -359,7 +359,7 @@ static enum TDB_ERROR tdb_nest_lock(struct tdb_context *tdb, static enum TDB_ERROR tdb_nest_unlock(struct tdb_context *tdb, tdb_off_t off, int ltype) { - struct tdb_lock_type *lck; + struct tdb_lock *lck; enum TDB_ERROR ecode; if (tdb->flags & TDB_NOLOCK) @@ -574,7 +574,7 @@ void tdb_allrecord_unlock(struct tdb_context *tdb, int ltype) && (!tdb->file->allrecord_lock.off || ltype != F_RDLCK)) { tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR, "tdb_allrecord_unlock: have %s lock", - tdb->allrecord_lock.ltype == F_RDLCK + tdb->file->allrecord_lock.ltype == F_RDLCK ? "read" : "write"); return; }