locking: Add handler function for locking a database
authorAmitay Isaacs <amitay@gmail.com>
Tue, 30 Apr 2013 04:06:27 +0000 (14:06 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 23 May 2013 23:06:38 +0000 (09:06 +1000)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
server/ctdb_lock.c

index 46fc57ae33fdec4857c6709a44190b5835ab4ab2..7bbab4ce6296ed5f7dce40d7fdc77fcb7290b697 100644 (file)
@@ -158,6 +158,26 @@ static int ctdb_db_iterator(struct ctdb_context *ctdb, uint32_t priority,
 /*
  * lock all databases
  */
+static int db_lock_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
+                          void *private_data)
+{
+       if (priority == 0) {
+               DEBUG(DEBUG_INFO, ("locking database %s\n",
+                                  ctdb_db->db_name));
+       } else {
+               DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
+                                  ctdb_db->db_name, priority));
+       }
+
+       if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
+               DEBUG(DEBUG_ERR, ("Failed to lock database %s\n",
+                                 ctdb_db->db_name));
+               return -1;
+       }
+
+       return 0;
+}
+
 int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t priority)
 {
        struct ctdb_db_context *ctdb_db;