diff options
author | Simo Sorce <idra@samba.org> | 2005-09-17 19:25:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:14 -0500 |
commit | 8919d6bf9a88ce9ac43dae61989c33082c984b66 (patch) | |
tree | 55302a32ab9da077db48a69313fe648abdf578c9 /source4/lib/ldb/common | |
parent | f1d065128d8715e9ee34a31bbdc60d9d4e00a6a8 (diff) | |
download | samba-8919d6bf9a88ce9ac43dae61989c33082c984b66.tar.gz samba-8919d6bf9a88ce9ac43dae61989c33082c984b66.tar.bz2 samba-8919d6bf9a88ce9ac43dae61989c33082c984b66.zip |
r10299: remove the public (un)lock functions and introduce a transaction based
private ldb API
ldb_sqlite3 is already working with this model and ldb_tdb will do
as soon as tridge finishes the tdb transaction code.
currently the transactions are always implicit and wrap any single
ldb API call except searching, the transaction functions are
currently not made public on purpose.
Simo.
(This used to be commit 1da4ac2cdcb7e54076f85242a93784260dced918)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb.c | 54 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb_modules.c | 8 |
2 files changed, 39 insertions, 23 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 25e7bee66b..ae71f08713 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -106,6 +106,22 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co } /* + start a transaction +*/ +static int ldb_start_trans(struct ldb_context *ldb) +{ + return ldb->modules->ops->start_transaction(ldb->modules); +} + +/* + end a transaction +*/ +static int ldb_end_trans(struct ldb_context *ldb, int status) +{ + return ldb->modules->ops->end_transaction(ldb->modules, status); +} + +/* search the database given a LDAP-like search expression return the number of records found, or -1 on error @@ -146,7 +162,11 @@ int ldb_search_bytree(struct ldb_context *ldb, int ldb_add(struct ldb_context *ldb, const struct ldb_message *message) { - return ldb->modules->ops->add_record(ldb->modules, message); + int status = ldb_start_trans(ldb); + if (status != 0) return status; + + status = ldb->modules->ops->add_record(ldb->modules, message); + return ldb_end_trans(ldb, status); } /* @@ -155,7 +175,11 @@ int ldb_add(struct ldb_context *ldb, int ldb_modify(struct ldb_context *ldb, const struct ldb_message *message) { - return ldb->modules->ops->modify_record(ldb->modules, message); + int status = ldb_start_trans(ldb); + if (status != 0) return status; + + status = ldb->modules->ops->modify_record(ldb->modules, message); + return ldb_end_trans(ldb, status); } @@ -164,7 +188,11 @@ int ldb_modify(struct ldb_context *ldb, */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn) { - return ldb->modules->ops->delete_record(ldb->modules, dn); + int status = ldb_start_trans(ldb); + if (status != 0) return status; + + status = ldb->modules->ops->delete_record(ldb->modules, dn); + return ldb_end_trans(ldb, status); } /* @@ -172,23 +200,11 @@ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn) */ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn) { - return ldb->modules->ops->rename_record(ldb->modules, olddn, newdn); -} + int status = ldb_start_trans(ldb); + if (status != 0) return status; -/* - create a named lock -*/ -int ldb_lock(struct ldb_context *ldb, const char *lockname) -{ - return ldb->modules->ops->named_lock(ldb->modules, lockname); -} - -/* - release a named lock -*/ -int ldb_unlock(struct ldb_context *ldb, const char *lockname) -{ - return ldb->modules->ops->named_unlock(ldb->modules, lockname); + status = ldb->modules->ops->rename_record(ldb->modules, olddn, newdn); + return ldb_end_trans(ldb, status); } /* diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 20e8ad061e..29bc8264e9 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -306,20 +306,20 @@ int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn return module->next->ops->rename_record(module->next, olddn, newdn); } -int ldb_next_named_lock(struct ldb_module *module, const char *lockname) +int ldb_next_start_trans(struct ldb_module *module) { if (!module->next) { return -1; } - return module->next->ops->named_lock(module->next, lockname); + return module->next->ops->start_transaction(module->next); } -int ldb_next_named_unlock(struct ldb_module *module, const char *lockname) +int ldb_next_end_trans(struct ldb_module *module, int status) { if (!module->next) { return -1; } - return module->next->ops->named_unlock(module->next, lockname); + return module->next->ops->end_transaction(module->next, status); } const char *ldb_next_errstring(struct ldb_module *module) |