summaryrefslogtreecommitdiff
path: root/src/providers/ldap/ldap_id_enum.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-06-09 10:34:47 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-06-10 10:17:38 -0400
commit476b2f491e248b182c0f6c3461028b61a8a87ab7 (patch)
tree895b46159f27d911d615e2e2471f59178a1b7d25 /src/providers/ldap/ldap_id_enum.c
parentbb1487fef5d19a7b1536fc42e25a08f7d4c43e1b (diff)
downloadsssd-476b2f491e248b182c0f6c3461028b61a8a87ab7.tar.gz
sssd-476b2f491e248b182c0f6c3461028b61a8a87ab7.tar.bz2
sssd-476b2f491e248b182c0f6c3461028b61a8a87ab7.zip
Properly check that the timeout event was created for cleanup/enum
We need to make sure that if we didn't create the timeout, that we cancel the request so there's no chance of ending up with two enumerations/cleanups running simultaneously. We'll attempt to reschedule later, if possible. https://fedorahosted.org/sssd/ticket/524
Diffstat (limited to 'src/providers/ldap/ldap_id_enum.c')
-rw-r--r--src/providers/ldap/ldap_id_enum.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
index 89ca2de7..95b35e0c 100644
--- a/src/providers/ldap/ldap_id_enum.c
+++ b/src/providers/ldap/ldap_id_enum.c
@@ -54,6 +54,7 @@ static void ldap_id_enumerate_timer(struct tevent_context *ev,
struct tevent_timer *timeout;
struct tevent_req *req;
int delay;
+ errno_t ret;
if (be_is_offline(ctx->be)) {
DEBUG(4, ("Backend is marked offline, retry later!\n"));
@@ -70,7 +71,10 @@ static void ldap_id_enumerate_timer(struct tevent_context *ev,
/* schedule starting from now, not the last run */
delay = dp_opt_get_int(ctx->opts->basic, SDAP_ENUM_REFRESH_TIMEOUT);
tv = tevent_timeval_current_ofs(delay, 0);
- ldap_id_enumerate_set_timer(ctx, tv);
+ ret = ldap_id_enumerate_set_timer(ctx, tv);
+ if (ret != EOK) {
+ DEBUG(1, ("Error setting up enumerate timer\n"));
+ }
return;
}
tevent_req_set_callback(req, ldap_id_enumerate_reschedule, ctx);
@@ -81,6 +85,24 @@ static void ldap_id_enumerate_timer(struct tevent_context *ev,
tv = tevent_timeval_current_ofs(delay, 0);
timeout = tevent_add_timer(ctx->be->ev, req, tv,
ldap_id_enumerate_timeout, req);
+ if (timeout == NULL) {
+ /* If we can't guarantee a timeout, we
+ * need to cancel the request, to avoid
+ * the possibility of starting another
+ * concurrently
+ */
+ talloc_zfree(req);
+
+ DEBUG(1, ("Failed to schedule enumeration, retrying later!\n"));
+ /* schedule starting from now, not the last run */
+ delay = dp_opt_get_int(ctx->opts->basic, SDAP_ENUM_REFRESH_TIMEOUT);
+ tv = tevent_timeval_current_ofs(delay, 0);
+ ret = ldap_id_enumerate_set_timer(ctx, tv);
+ if (ret != EOK) {
+ DEBUG(1, ("Error setting up enumerate timer\n"));
+ }
+ return;
+ }
return;
}