1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

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
This commit is contained in:
Andrew Tridgell 2009-09-04 13:59:44 +10:00
parent 5842aa1ffd
commit c298e660bd
2 changed files with 9 additions and 3 deletions

View File

@ -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);

View File

@ -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++;