]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Check for lock count underflow
authorMartin Schwenke <martin@meltin.net>
Mon, 17 Feb 2020 05:20:25 +0000 (16:20 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 18 Feb 2020 02:56:38 +0000 (02:56 +0000)
This is a programming error.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_lock.c

index 5f032ae568b7297df5470b92a0c742b527e23a74..478447d76f80b21d7b26c68ebcbc9aaf26adbb1e 100644 (file)
@@ -198,6 +198,9 @@ static int ctdb_lock_context_destructor(struct lock_context *lock_ctx)
                } else {
                        DLIST_REMOVE(lock_ctx->ctdb->lock_current, lock_ctx);
                }
+               if (lock_ctx->ctdb_db->lock_num_current == 0) {
+                       ctdb_fatal(NULL, "Lock count is 0 before decrement\n");
+               }
                lock_ctx->ctdb_db->lock_num_current--;
                CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_current);
                CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_current);