summaryrefslogtreecommitdiff
path: root/server/providers
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-09-11 11:33:00 -0400
committerSimo Sorce <ssorce@redhat.com>2009-09-11 16:22:42 -0400
commit81fdd5adc085c2cc3ff3b4a8ca309b91db30c5fe (patch)
tree48c3c8e0cf0d85387334da2a445f3bea0dd6a7df /server/providers
parentc8f8196386b54ba2caa506a2ce9db87b6a326084 (diff)
downloadsssd-81fdd5adc085c2cc3ff3b4a8ca309b91db30c5fe.tar.gz
sssd-81fdd5adc085c2cc3ff3b4a8ca309b91db30c5fe.tar.bz2
sssd-81fdd5adc085c2cc3ff3b4a8ca309b91db30c5fe.zip
Fix ldap enumeration async task
The request was being freed, instead of marking it done and let the callback free it when done. This was causing us to access freed memory, when trying to set the next run. Let the callback add new runs and free the request instead as normally we would do with any other tevent_req async call. Courtesy of valgrind again.
Diffstat (limited to 'server/providers')
-rw-r--r--server/providers/ldap/ldap_id.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/server/providers/ldap/ldap_id.c b/server/providers/ldap/ldap_id.c
index efd9e914..bebeea22 100644
--- a/server/providers/ldap/ldap_id.c
+++ b/server/providers/ldap/ldap_id.c
@@ -846,7 +846,6 @@ static void ldap_id_enumerate(struct tevent_context *ev,
ldap_id_enumerate_set_timer(ctx, tevent_timeval_current());
return;
}
-
tevent_req_set_callback(req, ldap_id_enumerate_reschedule, ctx);
/* if enumeration takes so long, either we try to enumerate too
@@ -877,6 +876,18 @@ static void ldap_id_enumerate_reschedule(struct tevent_req *req)
{
struct sdap_id_ctx *ctx = tevent_req_callback_data(req,
struct sdap_id_ctx);
+ struct timeval tv;
+ enum tevent_req_state tstate;
+ uint64_t err;
+
+ if (tevent_req_is_error(req, &tstate, &err)) {
+ /* On error schedule starting from now, not the last run */
+ tv = tevent_timeval_current();
+ } else {
+ tv = ctx->last_run;
+ }
+ talloc_zfree(req);
+
ldap_id_enumerate_set_timer(ctx, ctx->last_run);
}
@@ -965,10 +976,7 @@ fail:
}
DEBUG(1, ("Failed to enumerate users, retrying later!\n"));
- /* schedule starting from now, not the last run */
- ldap_id_enumerate_set_timer(state->ctx, tevent_timeval_current());
-
- talloc_zfree(req);
+ tevent_req_done(req);
}
static void ldap_id_enum_groups_done(struct tevent_req *subreq)
@@ -983,10 +991,9 @@ static void ldap_id_enum_groups_done(struct tevent_req *subreq)
if (tevent_req_is_error(subreq, &tstate, &err)) {
goto fail;
}
- talloc_zfree(req);
-
- ldap_id_enumerate_set_timer(state->ctx, state->ctx->last_run);
+ talloc_zfree(subreq);
+ tevent_req_done(req);
return;
fail:
@@ -995,10 +1002,7 @@ fail:
}
DEBUG(1, ("Failed to enumerate groups, retrying later!\n"));
- /* schedule starting from now, not the last run */
- ldap_id_enumerate_set_timer(state->ctx, tevent_timeval_current());
-
- talloc_zfree(req);
+ tevent_req_done(req);
}
/* ==User-Enumeration===================================================== */