summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-11 22:35:15 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:15 -0400
commitcc14edade621572cf4457d55d5b989029c5131ee (patch)
tree1fd1db93992a2d890f2d9e3115ad27b7b853181f
parent24a947aac2ead046940e9c23ee8393a115ee47a3 (diff)
downloadsssd-cc14edade621572cf4457d55d5b989029c5131ee.tar.gz
sssd-cc14edade621572cf4457d55d5b989029c5131ee.tar.bz2
sssd-cc14edade621572cf4457d55d5b989029c5131ee.zip
sysdb: add synchronous transaction functions
-rw-r--r--src/db/sysdb.c32
-rw-r--r--src/db/sysdb.h19
2 files changed, 37 insertions, 14 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 2daaa7bc..1f75bbe0 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -669,6 +669,38 @@ void sysdb_transaction_complete(struct tevent_req *subreq)
tevent_req_done(req);
}
+int sysdb_transaction_start(struct sysdb_ctx *ctx)
+{
+ int ret;
+
+ ret = ldb_transaction_start(ctx->ldb);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(1, ("Failed to start ldb transaction! (%d)\n", ret));
+ }
+ return sysdb_error_to_errno(ret);
+}
+
+int sysdb_transaction_commit(struct sysdb_ctx *ctx)
+{
+ int ret;
+
+ ret = ldb_transaction_commit(ctx->ldb);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(1, ("Failed to commit ldb transaction! (%d)\n", ret));
+ }
+ return sysdb_error_to_errno(ret);
+}
+
+int sysdb_transaction_cancel(struct sysdb_ctx *ctx)
+{
+ int ret;
+
+ ret = ldb_transaction_cancel(ctx->ldb);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(1, ("Failed to cancel ldb transaction! (%d)\n", ret));
+ }
+ return sysdb_error_to_errno(ret);
+}
/* =Operations============================================================ */
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 6d8e4770..6091e892 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -217,20 +217,11 @@ struct sysdb_ctx *sysdb_handle_get_ctx(struct sysdb_handle *handle);
int compare_ldb_dn_comp_num(const void *m1, const void *m2);
-/* function to start and finish a transaction
- * sysdb_transaction_send() will queue a request for a transaction
- * when it is done it will call the tevent_req callback, which must
- * retrieve the transaction handle using sysdb_transaction_recv()
- *
- * A transaction must be completed either by sending a commit:
- * sysdb_transaction_commit_send()/sysdb_transaction_commit_recv()
- * or by freeing the transaction handle (this will implicitly cause
- * a transaction cancelation).
- *
- * Transactions are serialized, no other transaction or operation can be
- * performed while a transaction is active. Multiple transaction request
- * are queued internally and served in order.
- */
+/* functions to start and finish transactions */
+int sysdb_transaction_start(struct sysdb_ctx *ctx);
+int sysdb_transaction_commit(struct sysdb_ctx *ctx);
+int sysdb_transaction_cancel(struct sysdb_ctx *ctx);
+
struct tevent_req *sysdb_transaction_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,