diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-03-11 23:33:20 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-12 09:22:15 -0400 |
commit | 7db27a6090eafc8a4f76d25c464d1341b8dc5b8a (patch) | |
tree | dc04256d4940bc9a8decb5d044f1f8c7bc30e155 /src | |
parent | d8d877a5fcde1defdd1a438df020e087339873a0 (diff) | |
download | sssd_unused-7db27a6090eafc8a4f76d25c464d1341b8dc5b8a.tar.gz sssd_unused-7db27a6090eafc8a4f76d25c464d1341b8dc5b8a.tar.xz sssd_unused-7db27a6090eafc8a4f76d25c464d1341b8dc5b8a.zip |
sysdb: remove async transactions
not used anymore
Diffstat (limited to 'src')
-rw-r--r-- | src/db/sysdb.c | 138 | ||||
-rw-r--r-- | src/db/sysdb.h | 19 |
2 files changed, 0 insertions, 157 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 1f75bbe0..22051da3 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -531,144 +531,6 @@ static int sysdb_get_handle_recv(struct tevent_req *req, TALLOC_CTX *memctx, /* =Transactions========================================================== */ -struct sysdb_transaction_state { - struct tevent_context *ev; - struct sysdb_ctx *ctx; - - struct sysdb_handle *handle; -}; - -static void sysdb_transaction_done(struct tevent_req *subreq); - -struct tevent_req *sysdb_transaction_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct sysdb_ctx *ctx) -{ - struct tevent_req *req, *subreq; - struct sysdb_transaction_state *state; - - req = tevent_req_create(mem_ctx, &state, struct sysdb_transaction_state); - if (!req) return NULL; - - state->ev = ev; - state->ctx = ctx; - - subreq = sysdb_get_handle_send(state, ev, ctx); - if (!subreq) { - talloc_zfree(req); - return NULL; - } - - tevent_req_set_callback(subreq, sysdb_transaction_done, req); - - return req; -} - -static void sysdb_transaction_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data(subreq, - struct tevent_req); - struct sysdb_transaction_state *state = tevent_req_data(req, - struct sysdb_transaction_state); - int ret; - - ret = sysdb_get_handle_recv(subreq, state, &state->handle); - talloc_zfree(subreq); - if (ret) { - tevent_req_error(req, ret); - return; - } - - ret = ldb_transaction_start(state->ctx->ldb); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Failed to start ldb transaction! (%d)\n", ret)); - tevent_req_error(req, sysdb_error_to_errno(ret)); - return; - } - state->handle->transaction_active = true; - - tevent_req_done(req); -} - -int sysdb_transaction_recv(struct tevent_req *req, TALLOC_CTX *memctx, - struct sysdb_handle **handle) -{ - struct sysdb_transaction_state *state = tevent_req_data(req, - struct sysdb_transaction_state); - - TEVENT_REQ_RETURN_ON_ERROR(req); - - *handle = talloc_steal(memctx, state->handle); - if (!*handle) return ENOMEM; - - return EOK; -} - -struct tevent_req *sysdb_transaction_commit_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct sysdb_handle *handle) -{ - struct tevent_req *req; - struct sysdb_transaction_state *state; - int ret; - - req = tevent_req_create(mem_ctx, &state, struct sysdb_transaction_state); - if (!req) return NULL; - - state->ev = ev; - state->ctx = handle->ctx; - state->handle = handle; - - ret = ldb_transaction_commit(handle->ctx->ldb); - if (ret != LDB_SUCCESS) { - DEBUG(1, ("Failed to commit ldb transaction! (%d)\n", ret)); - tevent_req_error(req, sysdb_error_to_errno(ret)); - } - handle->transaction_active = false; - - /* the following may seem weird but it is actually fine. - * _done() will not actually call the callback as it will not be set - * until we return. But it will mark the request as done. - * _post() will trigger the callback as it schedules after we returned - * and actually set the callback */ - tevent_req_done(req); - tevent_req_post(req, ev); - return req; -} - -int sysdb_transaction_commit_recv(struct tevent_req *req) -{ - struct sysdb_transaction_state *state = tevent_req_data(req, - struct sysdb_transaction_state); - - /* finally free handle - * this will also trigger the next transaction in the queue if any */ - talloc_zfree(state->handle); - - TEVENT_REQ_RETURN_ON_ERROR(req); - - return EOK; -} - -/* default transaction commit receive function. - * This function does not use the request state so it is safe to use - * from any caller */ -void sysdb_transaction_complete(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data(subreq, - struct tevent_req); - int ret; - - ret = sysdb_transaction_commit_recv(subreq); - talloc_zfree(subreq); - if (ret) { - tevent_req_error(req, ret); - return; - } - - tevent_req_done(req); -} - int sysdb_transaction_start(struct sysdb_ctx *ctx) { int ret; diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 6091e892..7da98fa8 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -222,25 +222,6 @@ 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, - struct sysdb_ctx *ctx); -int sysdb_transaction_recv(struct tevent_req *req, TALLOC_CTX *memctx, - struct sysdb_handle **handle); - -struct tevent_req *sysdb_transaction_commit_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct sysdb_handle *handle); -int sysdb_transaction_commit_recv(struct tevent_req *req); - - -/* default transaction commit receive function. - * This function does not use the request state so it is safe to use - * from any caller */ -void sysdb_transaction_complete(struct tevent_req *subreq); - - /* Sysdb initialization. * call this function *only* once to initialize the database and get * the sysdb ctx */ |