/* * 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; } } }
/* * 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; bool auto_mark = lock_ctx->auto_mark; if (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: ctdb_lockdb_mark(lock_ctx->ctdb_db); break; } } request = lock_ctx->request; if (auto_mark) { /* Since request may be freed in the callback, unset the lock * context, so request destructor will not free lock context. */ request->lctx = NULL; } /* Since request may be freed in the callback, unset the request */ lock_ctx->request = NULL; request->callback(request->private_data, locked); if (!auto_mark) { return; } if (locked) { switch (lock_ctx->type) { case LOCK_RECORD: tdb_chainlock_unmark(lock_ctx->ctdb_db->ltdb->tdb, lock_ctx->key); break; case LOCK_DB: ctdb_lockdb_unmark(lock_ctx->ctdb_db); break; } } talloc_free(lock_ctx); }