/* * Process all the callbacks waiting for lock * * If lock has failed, callback is executed with locked=false */ static void process_callbacks(struct lock_context *lock_ctx, bool locked) { struct lock_request *request, *next; if (lock_ctx->auto_mark && locked) { switch (lock_ctx->type) { case LOCK_RECORD: tdb_chainlock_mark(lock_ctx->ctdb_db->ltdb->tdb, lock_ctx->key); break; case LOCK_DB: tdb_lockall_mark(lock_ctx->ctdb_db->ltdb->tdb); break; case LOCK_ALLDB_PRIO: ctdb_lockall_mark_prio(lock_ctx->ctdb, lock_ctx->priority); break; case LOCK_ALLDB: ctdb_lockall_mark(lock_ctx->ctdb); break; } } /* Iterate through all callbacks */ request = lock_ctx->req_queue; while (request) { if (lock_ctx->auto_mark) { /* Reset the destructor, so request is not removed from the list */ talloc_set_destructor(request, NULL); } /* In case, callback frees the request, store next */ next = request->next; request->callback(request->private_data, locked); request = next; } if (lock_ctx->auto_mark && locked) { switch (lock_ctx->type) { case LOCK_RECORD: tdb_chainlock_unmark(lock_ctx->ctdb_db->ltdb->tdb, lock_ctx->key); break; case LOCK_DB: tdb_lockall_unmark(lock_ctx->ctdb_db->ltdb->tdb); break; case LOCK_ALLDB_PRIO: ctdb_lockall_unmark_prio(lock_ctx->ctdb, lock_ctx->priority); break; case LOCK_ALLDB: ctdb_lockall_unmark(lock_ctx->ctdb); break; } } }
/* * lock all databases - unmark only */ static int db_lock_unmark_handler(struct ctdb_db_context *ctdb_db, void *private_data) { int tdb_transaction_write_lock_unmark(struct tdb_context *); DEBUG(DEBUG_INFO, ("unmarking locked database %s\n", ctdb_db->db_name)); if (tdb_transaction_write_lock_unmark(ctdb_db->ltdb->tdb) != 0) { DEBUG(DEBUG_ERR, ("Failed to unmark (transaction lock) database %s\n", ctdb_db->db_name)); return -1; } if (tdb_lockall_unmark(ctdb_db->ltdb->tdb) != 0) { DEBUG(DEBUG_ERR, ("Failed to unmark (all lock) database %s\n", ctdb_db->db_name)); return -1; } return 0; }