From 21d485184df986e1a123f70c689517386e51a5ce Mon Sep 17 00:00:00 2001 From: Michal Zidek Date: Thu, 16 Aug 2012 18:48:53 +0200 Subject: Unify usage of sysdb transactions Removing bad examples of usage of sysdb_transaction_start/commit/end functions and making it more consistent (all files except of src/db/sysdb_*.c). --- src/providers/ipa/ipa_selinux_common.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/providers/ipa/ipa_selinux_common.c') diff --git a/src/providers/ipa/ipa_selinux_common.c b/src/providers/ipa/ipa_selinux_common.c index a01e0b6c..45794388 100644 --- a/src/providers/ipa/ipa_selinux_common.c +++ b/src/providers/ipa/ipa_selinux_common.c @@ -32,12 +32,16 @@ errno_t ipa_save_user_maps(struct sysdb_ctx *sysdb, struct sysdb_attrs **maps) { errno_t ret; + errno_t sret; + bool in_transaction = false; int i; ret = sysdb_transaction_start(sysdb); if (ret) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n")); goto done; } + in_transaction = true; for (i = 0; i < map_count; i++) { ret = sysdb_store_selinux_usermap(sysdb, maps[i]); @@ -54,9 +58,15 @@ errno_t ipa_save_user_maps(struct sysdb_ctx *sysdb, DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction!\n")); goto done; } - + in_transaction = false; ret = EOK; done: + if (in_transaction) { + sret = sysdb_transaction_cancel(sysdb); + if (sret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to cancel transaction")); + } + } return ret; } -- cgit