summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-04 13:59:44 +1000
committerAndrew Tridgell <tridge@samba.org>2009-09-04 14:40:51 +1000
commitc298e660bd28140125f2ac6b47dff6d7c01e82ae (patch)
treecc7f4aba631ae803cc22fbb1654aa42db4e4260d /source4
parent5842aa1ffdedd192d2616a6593bc8d8464dde3cd (diff)
downloadsamba-c298e660bd28140125f2ac6b47dff6d7c01e82ae.tar.gz
samba-c298e660bd28140125f2ac6b47dff6d7c01e82ae.tar.bz2
samba-c298e660bd28140125f2ac6b47dff6d7c01e82ae.zip
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
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/tools/ldbadd.c10
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
2 files changed, 9 insertions, 3 deletions
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);
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 9653eabcb9..ecadf0f61c 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -128,6 +128,7 @@ static int merge_edits(struct ldb_context *ldb,
fprintf(stderr, "failed to add %s - %s\n",
ldb_dn_get_linearized(msgs2[i]->dn),
ldb_errstring(ldb));
+ ldb_transaction_cancel(ldb);
return -1;
}
adds++;
@@ -149,6 +150,7 @@ static int merge_edits(struct ldb_context *ldb,
fprintf(stderr, "failed to delete %s - %s\n",
ldb_dn_get_linearized(msgs1[i]->dn),
ldb_errstring(ldb));
+ ldb_transaction_cancel(ldb);
return -1;
}
deletes++;