From bd93ef2db6d24946ebf98a23fa18d34d45f6b072 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 29 Feb 2016 13:22:18 +0100 Subject: SYSDB: Track transaction nesting in sysdb_ctx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Lukáš Slebodník --- src/db/sysdb.c | 12 +++++++++--- src/db/sysdb_private.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/db') diff --git a/src/db/sysdb.c b/src/db/sysdb.c index d7540f0cc..0d2f4f06d 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -917,7 +917,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); } @@ -929,7 +931,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); } @@ -941,7 +945,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 4b1667ca4..d0837fe23 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 */ -- cgit