summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-01-20 14:16:23 -0500
committerStephen Gallagher <sgallagh@redhat.com>2011-02-03 12:16:13 -0500
commitf716f4d39d5165da873ac923c9832a16c9a97f55 (patch)
treea31d3399b902613c8a0431d20ceb64163189d4a1 /src
parentcfd96684dae08a373fdeff14e5dfcd58dce1ef57 (diff)
downloadsssd-f716f4d39d5165da873ac923c9832a16c9a97f55.tar.gz
sssd-f716f4d39d5165da873ac923c9832a16c9a97f55.tar.bz2
sssd-f716f4d39d5165da873ac923c9832a16c9a97f55.zip
Wrap cleanup task in a sysdb transaction
Diffstat (limited to 'src')
-rw-r--r--src/providers/ldap/ldap_id_cleanup.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c
index 293681cf..ced46522 100644
--- a/src/providers/ldap/ldap_id_cleanup.c
+++ b/src/providers/ldap/ldap_id_cleanup.c
@@ -181,6 +181,7 @@ struct tevent_req *ldap_id_cleanup_send(TALLOC_CTX *memctx,
struct global_cleanup_state *state;
struct tevent_req *req;
int ret;
+ bool in_transaction = false;
req = tevent_req_create(memctx, &state, struct global_cleanup_state);
if (!req) return NULL;
@@ -190,6 +191,11 @@ struct tevent_req *ldap_id_cleanup_send(TALLOC_CTX *memctx,
ctx->last_purge = tevent_timeval_current();
+ ret = sysdb_transaction_start(state->ctx->be->sysdb);
+ if (ret != EOK) {
+ goto fail;
+ }
+
ret = cleanup_users(state, state->ctx);
if (ret && ret != ENOENT) {
goto fail;
@@ -202,6 +208,11 @@ struct tevent_req *ldap_id_cleanup_send(TALLOC_CTX *memctx,
goto fail;
}
+ ret = sysdb_transaction_commit(state->ctx->be->sysdb);
+ if (ret != EOK) {
+ goto fail;
+ }
+
tevent_req_done(req);
tevent_req_post(req, ev);
return req;
@@ -209,6 +220,15 @@ struct tevent_req *ldap_id_cleanup_send(TALLOC_CTX *memctx,
fail:
DEBUG(1, ("Failed to cleanup caches (%d [%s]), retrying later!\n",
(int)ret, strerror(ret)));
+ if (in_transaction) {
+ ret = sysdb_transaction_cancel(state->ctx->be->sysdb);
+ if (ret != EOK) {
+ DEBUG(1, ("Could not cancel transaction\n"));
+ tevent_req_error(req, ret);
+ tevent_req_post(req, ev);
+ return req;
+ }
+ }
tevent_req_done(req);
tevent_req_post(req, ev);
return req;