From 755350f1a5881a14484bc7434ec0ddc12498373f Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Tue, 9 Oct 2012 15:17:58 +0200 Subject: Add more debug information to getpwent process --- src/responder/nss/nsssrv_cmd.c | 43 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 6848413d..00eff713 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -1520,8 +1520,13 @@ static int nss_cmd_getpwent(struct cli_ctx *cctx) cmdctx->saved_dom_idx = cctx->pwent_dom_idx; cmdctx->saved_cur = cctx->pwent_cur; + DEBUG(0, ("dom_idx: %d, pwent_cur: %d\n", + cctx->pwent_dom_idx, cctx->pwent_cur)); + nctx = talloc_get_type(cctx->rctx->pvt_ctx, struct nss_ctx); if(!nctx->pctx || !nctx->pctx->ready) { + DEBUG(0, ("No data available. Calling implicit setpwent\n")); + /* Make sure we invoke setpwent if it hasn't been run or is still * processing from another client */ @@ -1560,6 +1565,8 @@ static int nss_cmd_getpwent_immediate(struct nss_cmd_ctx *cmdctx) return ret; } + DEBUG(0, ("Calling nss_cmd_retpwen(%p, %d)\n", cctx, num)); + ret = nss_cmd_retpwent(cctx, num); sss_packet_set_error(cctx->creq->out, ret); @@ -1588,14 +1595,34 @@ static int nss_cmd_retpwent(struct cli_ctx *cctx, int num) pdom = &pctx->doms[cctx->pwent_dom_idx]; n = pdom->res->count - cctx->pwent_cur; + + DEBUG(0, ("Current domain: %d Total: %d\n", + cctx->pwent_dom_idx, pctx->num)); + DEBUG(0, ("Requested: %d Total: %d Current: %d Diff: %d\n", + num, pdom->res->count, cctx->pwent_cur, n)); + if (n <= 0 && (cctx->pwent_dom_idx+1 < pctx->num)) { cctx->pwent_dom_idx++; pdom = &pctx->doms[cctx->pwent_dom_idx]; n = pdom->res->count; cctx->pwent_cur = 0; + + DEBUG(0, ("Continuing with next domain...\n")); + DEBUG(0, ("Current domain: %d Total: %d\n", + cctx->pwent_dom_idx, pctx->num)); + DEBUG(0, ("Requested: %d Total: %d Current: %d Diff: %d\n", + num, pdom->res->count, cctx->pwent_cur, n)); } - if (!n) break; + if (n == 0) { + DEBUG(0, ("OK n == 0. No more users to return. Breaking loop...\n")); + break; + } + + if (n < 0) { + DEBUG(0, ("ERROR n < 0. Breaking loop...\n")); + break; + } if (n > num) n = num; @@ -1608,8 +1635,12 @@ static int nss_cmd_retpwent(struct cli_ctx *cctx, int num) none: if (ret == ENOENT) { + DEBUG(0, ("Creating empty data\n")); ret = fill_empty(cctx->creq->out); } + + DEBUG(0, ("Returning data...\n")); + return ret; } @@ -1636,6 +1667,9 @@ static void nss_cmd_implicit_setpwent_done(struct tevent_req *req) cmdctx->cctx->pwent_dom_idx = cmdctx->saved_dom_idx; cmdctx->cctx->pwent_cur = cmdctx->saved_cur; + DEBUG(0, ("restoring dom_idx: %d, pwent_cur: %d\n", + cmdctx->saved_dom_idx, cmdctx->saved_cur)); + ret = nss_cmd_getpwent_immediate(cmdctx); if (ret != EOK) { DEBUG(0, ("Immediate retrieval failed with unexpected error " @@ -1659,9 +1693,14 @@ static int nss_cmd_endpwent(struct cli_ctx *cctx) &cctx->creq->out); if (ret != EOK) { + DEBUG(0, ("sss_packet_new() failed, counters are not reseted " + "[%d] - %s\n", ret, strerror(ret))); return ret; } - if (nctx->pctx == NULL) goto done; + if (nctx->pctx == NULL) { + DEBUG(0, ("nctx->pctx == NULL, counters are not reseted\n")); + goto done; + } /* Reset the indices so that subsequent requests start at zero */ cctx->pwent_dom_idx = 0; -- cgit