From 77dad909fe79d6aaa7aa90e810cb9bb2ddc240ad 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 3c888a42ca6f3b3e37b9f63e35c31bb7d5ffc367..f9b9b3ff864eef187eb0d3d79796e4000e56addf 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 4b1667ca41ca570851d5841aeb441dddd09cd2cf..d0837fe232425a61a932ce81ff8ba1b0fe4bafc6 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