[SSSD] [PATCH] Better cleanup task handling
Simo Sorce
ssorce at redhat.com
Tue Feb 23 17:19:03 UTC 2010
On Tue, 23 Feb 2010 13:50:42 +0100
Jakub Hrozek <jhrozek at redhat.com> wrote:
> if (!req) {
> @@ -281,19 +286,41 @@ static struct tevent_req
> *cleanup_users_send(TALLOC_CTX *memctx, }
>
> state->ev = ev;
> - state->sysdb = sysdb;
> - state->domain = domain;
> + state->sysdb = ctx->be->sysdb;
> + state->domain = ctx->be->domain;
> + state->ctx = ctx;
> state->msgs = NULL;
> state->count = 0;
> state->cur = 0;
>
> - subfilter = talloc_asprintf(state, "(&(!(%s=0))(%s<=%ld))",
> + login_cred_expiration = dp_opt_get_int(state->ctx->opts->basic,
> + SDAP_LOGIN_CACHE_TIMEOUT);
> + DEBUG(9, ("Cache expiration is set to %d days\n",
> login_cred_expiration)); +
> + subfilter = talloc_asprintf(state,
> + "(&(!(%s=0))(%s<=%ld)",
> SYSDB_CACHE_EXPIRE,
> - SYSDB_CACHE_EXPIRE, (long)now);
> + SYSDB_CACHE_EXPIRE,
> + (long) now);
> if (!subfilter) {
> DEBUG(2, ("Failed to build filter\n"));
> - talloc_zfree(req);
> - return NULL;
> + tevent_req_error(req, ENOMEM);
> + }
this change looks wrong ^^^^
> + if (login_cred_expiration > 0) {
> + subfilter = talloc_asprintf_append(subfilter,
> + "(|(!(%s=*))(%s<=%ld)))",
> + SYSDB_LAST_LOGIN,
> + SYSDB_LAST_LOGIN,
> + (long) (now - (login_cred_expiration
> * 86400)));
> + } else {
> + subfilter = talloc_asprintf_append(subfilter,
> + "(!(%s=*)))",
> + SYSDB_LAST_LOGIN);
> + }
> + if (!subfilter) {
> + DEBUG(2, ("Failed to build filter\n"));
> + tevent_req_error(req, ENOMEM);
> }
this looks wrong ^^^^
> subreq = sysdb_search_users_send(state, state->ev,
> @@ -301,11 +328,9 @@ static struct tevent_req
> *cleanup_users_send(TALLOC_CTX *memctx, state->domain, subfilter,
> attrs);
> if (!subreq) {
> DEBUG(2, ("Failed to send entry search\n"));
> - talloc_zfree(req);
> - return NULL;
> + tevent_req_error(req, ENOMEM);
> }
this looks wrong ^^^^
> tevent_req_set_callback(subreq, cleanup_users_process, req);
> -
> return req;
> }
>
Why did you change these error conditions ?
You do not return on error and you are setting an error without a
tevent_req_post() in the call that creates the request.
Simo.
--
Simo Sorce * Red Hat, Inc * New York
More information about the sssd-devel
mailing list