tdb2: allow multiple chain locks.
[ccan] / ccan / tdb2 / lock.c
index 2878eaeee5e98a9a034005a9dd0e626fa733ffc0..4033d0afe813e59bf4dee4b8bcc9e5d34757c298 100644 (file)
@@ -104,9 +104,9 @@ static int lock(struct tdb_context *tdb,
                tdb->file->locker = getpid();
        }
 
-       add_stat(tdb, lock_lowlevel, 1);
+       tdb->stats.lock_lowlevel++;
        if (!waitflag)
-               add_stat(tdb, lock_nonblock, 1);
+               tdb->stats.lock_nonblock++;
        return tdb->lock_fn(tdb->file->fd, rw, off, len, waitflag,
                            tdb->lock_data);
 }
@@ -359,7 +359,7 @@ static enum TDB_ERROR tdb_nest_lock(struct tdb_context *tdb,
                return TDB_ERR_LOCK;
        }
 
-       add_stat(tdb, locks, 1);
+       tdb->stats.locks++;
 
        new_lck = find_nestlock(tdb, offset, NULL);
        if (new_lck) {
@@ -378,12 +378,14 @@ static enum TDB_ERROR tdb_nest_lock(struct tdb_context *tdb,
                return TDB_SUCCESS;
        }
 
+#if 0
        if (tdb->file->num_lockrecs
            && offset >= TDB_HASH_LOCK_START
            && offset < TDB_HASH_LOCK_START + TDB_HASH_LOCK_RANGE) {
                return tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR,
                                  "tdb_nest_lock: already have a hash lock?");
        }
+#endif
 
        new_lck = (struct tdb_lock *)realloc(
                tdb->file->lockrecs,
@@ -567,7 +569,7 @@ enum TDB_ERROR tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
                                  " can't upgrade a write lock");
        }
 
-       add_stat(tdb, locks, 1);
+       tdb->stats.locks++;
 again:
        /* Lock hashes, gradually. */
        ecode = tdb_lock_gradual(tdb, ltype, flags, TDB_HASH_LOCK_START,