From c298e660bd28140125f2ac6b47dff6d7c01e82ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 4 Sep 2009 13:59:44 +1000 Subject: ldb: ensure we cancel a ldb transaction When we fail a ldbadd or ldbedit we should cancel the transaction to prevent ldb giving a warning about having a open transaction in the ldb destructor --- source4/lib/ldb/tools/ldbadd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 086540dfdf..f022486db8 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -109,9 +109,13 @@ int main(int argc, const char **argv) } } - if (count != 0 && ldb_transaction_commit(ldb) != 0) { - printf("Failed to commit transaction: %s\n", ldb_errstring(ldb)); - exit(1); + if (count != 0) { + if (ldb_transaction_commit(ldb) != 0) { + printf("Failed to commit transaction: %s\n", ldb_errstring(ldb)); + exit(1); + } + } else { + ldb_transaction_cancel(ldb); } talloc_free(ldb); -- cgit