summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 293681cf4..ced46522c 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;