From 59697d119f2bcf93b69dbb2afa6bead8b35ab752 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 29 Feb 2016 13:22:18 +0100 Subject: [PATCH 03/10] SYSDB: Track transaction nesting in sysdb_ctx Adds an integer that tracks how deeply nested we are in sysdb transactions. This will become useful later, because generally we are only interested in level-0 transactions when probing, so we'll want to pass the transaction nesting to the systemtap probes. --- src/db/sysdb.c | 12 +++++++++--- src/db/sysdb_private.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/db/sysdb.c b/src/db/sysdb.c index d4366a3c76f114bf113567754a1e0417afe664e3..0c1dda7b888a80912eeee7bbbda4584a4bd6344e 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -895,7 +895,9 @@ int sysdb_transaction_start(struct sysdb_ctx *sysdb) int ret; ret = ldb_transaction_start(sysdb->ldb); - if (ret != LDB_SUCCESS) { + if (ret == LDB_SUCCESS) { + sysdb->transaction_nesting++; + } else { DEBUG(SSSDBG_CRIT_FAILURE, "Failed to start ldb transaction! (%d)\n", ret); } @@ -907,7 +909,9 @@ int sysdb_transaction_commit(struct sysdb_ctx *sysdb) int ret; ret = ldb_transaction_commit(sysdb->ldb); - if (ret != LDB_SUCCESS) { + if (ret == LDB_SUCCESS) { + sysdb->transaction_nesting--; + } else { DEBUG(SSSDBG_CRIT_FAILURE, "Failed to commit ldb transaction! (%d)\n", ret); } @@ -919,7 +923,9 @@ int sysdb_transaction_cancel(struct sysdb_ctx *sysdb) int ret; ret = ldb_transaction_cancel(sysdb->ldb); - if (ret != LDB_SUCCESS) { + if (ret == LDB_SUCCESS) { + sysdb->transaction_nesting--; + } else { DEBUG(SSSDBG_CRIT_FAILURE, "Failed to cancel ldb transaction! (%d)\n", ret); } diff --git a/src/db/sysdb_private.h b/src/db/sysdb_private.h index c2c8d7a0585463806997c43bd020436edddd8517..b6c7fd162989aac3ae17da269fa4b1d967ca40f0 100644 --- a/src/db/sysdb_private.h +++ b/src/db/sysdb_private.h @@ -89,6 +89,7 @@ struct sysdb_ctx { struct ldb_context *ldb; char *ldb_file; + int transaction_nesting; }; /* Internal utility functions */ -- 2.4.11