summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_tdb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-09-24 15:42:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:52 -0500
commit63b43dd12fb579aaaccedd07aaa630cb1cd7aa88 (patch)
treed54cc9e41c4410c2a2e42f7479ff52a1fa0c156b /source4/lib/ldb/ldb_tdb/ldb_tdb.c
parent70b52b02a77c695d32aa57daaeb5689cd6857eba (diff)
downloadsamba-63b43dd12fb579aaaccedd07aaa630cb1cd7aa88.tar.gz
samba-63b43dd12fb579aaaccedd07aaa630cb1cd7aa88.tar.bz2
samba-63b43dd12fb579aaaccedd07aaa630cb1cd7aa88.zip
r10477: expose transactions outside ldb and change the API once more
do not autostart transactions on ldb operations if a transaction is already in place test transactions on winsdb all my tests passes so far tridge please confirm this is ok for you (This used to be commit c2bb2a36bdbe0ec7519697a9a9ba7526a0defac2)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_tdb.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index d8a03c3f55..701ed602ce 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -193,7 +193,7 @@ static int ltdb_add(struct ldb_module *module, const struct ldb_message *msg)
int ret;
ret = ltdb_check_special_dn(module, msg);
- if (ret != LDB_ERR_SUCCESS) {
+ if (ret != LDB_SUCCESS) {
return ret;
}
@@ -203,7 +203,7 @@ static int ltdb_add(struct ldb_module *module, const struct ldb_message *msg)
ret = ltdb_store(module, msg, TDB_INSERT);
- if (ret == LDB_ERR_SUCCESS) {
+ if (ret == LDB_SUCCESS) {
ltdb_modified(module, msg->dn);
}
@@ -261,13 +261,13 @@ static int ltdb_delete(struct ldb_module *module, const struct ldb_dn *dn)
}
ret = ltdb_delete_noindex(module, dn);
- if (ret != LDB_ERR_SUCCESS) {
+ if (ret != LDB_SUCCESS) {
goto failed;
}
/* remove any indexed attributes */
ret = ltdb_index_del(module, msg);
- if (ret == LDB_ERR_SUCCESS) {
+ if (ret == LDB_SUCCESS) {
ltdb_modified(module, dn);
} else
ret = LDB_ERR_OTHER;
@@ -605,7 +605,7 @@ static int ltdb_modify(struct ldb_module *module, const struct ldb_message *msg)
ret = ltdb_modify_internal(module, msg);
- if (ret == LDB_ERR_SUCCESS) {
+ if (ret == LDB_SUCCESS) {
ltdb_modified(module, msg->dn);
}
@@ -646,13 +646,13 @@ static int ltdb_rename(struct ldb_module *module, const struct ldb_dn *olddn, co
}
ret = ltdb_add(module, msg);
- if (ret != LDB_ERR_SUCCESS) {
+ if (ret != LDB_SUCCESS) {
goto failed;
}
ret = ltdb_delete(module, olddn);
error_str = talloc_strdup(module, ldb_errstring(module->ldb));
- if (ret != LDB_ERR_SUCCESS) {
+ if (ret != LDB_SUCCESS) {
ltdb_delete(module, newdn);
}
@@ -675,24 +675,29 @@ static int ltdb_start_trans(struct ldb_module *module)
return LDB_ERR_OPERATIONS_ERROR;
}
- return LDB_ERR_SUCCESS;
+ return LDB_SUCCESS;
}
-static int ltdb_end_trans(struct ldb_module *module, int status)
+static int ltdb_end_trans(struct ldb_module *module)
{
struct ltdb_private *ltdb = module->private_data;
- if (status != LDB_ERR_SUCCESS) {
- if (tdb_transaction_cancel(ltdb->tdb) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- } else {
- if (tdb_transaction_commit(ltdb->tdb) != 0) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
+ if (tdb_transaction_commit(ltdb->tdb) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ return LDB_SUCCESS;
+}
+
+static int ltdb_del_trans(struct ldb_module *module)
+{
+ struct ltdb_private *ltdb = module->private_data;
+
+ if (tdb_transaction_cancel(ltdb->tdb) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- return status;
+ return LDB_SUCCESS;
}
static const struct ldb_module_ops ltdb_ops = {
@@ -704,7 +709,8 @@ static const struct ldb_module_ops ltdb_ops = {
.delete_record = ltdb_delete,
.rename_record = ltdb_rename,
.start_transaction = ltdb_start_trans,
- .end_transaction = ltdb_end_trans
+ .end_transaction = ltdb_end_trans,
+ .del_transaction = ltdb_del_trans
};