From c5c79d63f2e51f1e38dc48880d2cb02bbd5312be Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 30 Apr 2013 14:10:06 +1000 Subject: [PATCH] locking: Use database iterator for unlocking databases Signed-off-by: Amitay Isaacs (This used to be ctdb commit 187ed83f9701c7fa8d3cc476d47c5d2a87d5c308) --- ctdb/server/ctdb_lock.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c index 5b183fc0036..f6220e02033 100644 --- a/ctdb/server/ctdb_lock.c +++ b/ctdb/server/ctdb_lock.c @@ -222,22 +222,7 @@ static int db_unlock_handler(struct ctdb_db_context *ctdb_db, uint32_t priority, int ctdb_unlockall_prio(struct ctdb_context *ctdb, uint32_t priority) { - struct ctdb_db_context *ctdb_db; - - for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) { - if (ctdb_db->priority != priority) { - continue; - } - DEBUG(DEBUG_INFO, ("unlocking database %s, priority:%u\n", - ctdb_db->db_name, priority)); - if (tdb_unlockall(ctdb_db->ltdb->tdb) != 0) { - DEBUG(DEBUG_ERR, ("Failed to unlock database %s\n", - ctdb_db->db_name)); - return -1; - } - } - - return 0; + return ctdb_db_iterator(ctdb, priority, db_unlock_handler, NULL); } static int ctdb_unlockall(struct ctdb_context *ctdb) @@ -245,7 +230,7 @@ static int ctdb_unlockall(struct ctdb_context *ctdb) uint32_t priority; for (priority=NUM_DB_PRIORITIES; priority>=0; priority--) { - if (ctdb_unlockall_prio(ctdb, priority) != 0) { + if (ctdb_db_iterator(ctdb, priority, db_unlock_handler, NULL) != 0) { return -1; } } -- 2.34.1