ctdb-locking: Add ctdb_db_iterator to iterate through all databases
authorAmitay Isaacs <amitay@gmail.com>
Tue, 5 Aug 2014 06:49:06 +0000 (16:49 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 7 Oct 2015 12:53:26 +0000 (14:53 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/include/ctdb_private.h
ctdb/server/ctdb_lock.c

index fad09d1de939fdcb0954bb3490674927b710f88b..8a906e58a6bf22ff52376372d020549183f7d37a 100644 (file)
@@ -1464,6 +1464,8 @@ typedef int (*ctdb_db_handler_t)(struct ctdb_db_context *ctdb_db,
 
 int ctdb_db_prio_iterator(struct ctdb_context *ctdb, uint32_t priority,
                          ctdb_db_handler_t handler, void *private_data);
+int ctdb_db_iterator(struct ctdb_context *ctdb, ctdb_db_handler_t handler,
+                    void *private_data);
 
 int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority);
 int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority);
index 63652b5624f4d21a78bf3c16e97931e5badff539..2ef5b21464695d190d8d06e02eb6079aa26a87aa 100644 (file)
@@ -150,6 +150,21 @@ int ctdb_db_prio_iterator(struct ctdb_context *ctdb, uint32_t priority,
        return 0;
 }
 
+int ctdb_db_iterator(struct ctdb_context *ctdb, ctdb_db_handler_t handler,
+                    void *private_data)
+{
+       struct ctdb_db_context *ctdb_db;
+       int ret;
+
+       for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
+               ret = handler(ctdb_db, private_data);
+               if (ret != 0) {
+                       return -1;
+               }
+       }
+
+       return 0;
+}
 
 /*
  * lock all databases - mark only