From 11240f2a106984191860fc86e8b20093c43a9ace 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 d7540f0ccbe7de38f840f84dbe8f51f4793821bc..0d2f4f06d8a3cbe44bdc190453bd0e523dd34aa5 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 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