]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbindd: Change the TALLOC_CTX to fix the tevent call depth tracking
authorPavel Filipenský <pfilipensky@samba.org>
Wed, 19 Jul 2023 09:33:56 +0000 (11:33 +0200)
committerPavel Filipensky <pfilipensky@samba.org>
Thu, 20 Jul 2023 10:38:19 +0000 (10:38 +0000)
Call depth is not working for winbindd_list_users_send as expected,
it is visible in the flow traces:

  -> process_request_send
      -> winbindd_list_users_send
  -> wb_query_user_list_send

It should look like:

  -> process_request_send
      -> winbindd_list_users_send
          -> wb_query_user_list_send

Tevent call depth tracking internal implementation relies on the fact
that the talloc memory context has type  "struct tevent_req".
Then it can obtain the depth from the parent and increment it by one.

The implementation of winbindd_list_users_send() is passing to
wb_query_user_list_send() context of type
"struct winbindd_list_users_state", and from there the parent
"struct tevent_req" cannot be identified.

So we will pass as TALLOC_CTX 'state' instead of 'state->domains'.
After the call, we can reparent back.

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Thu Jul 20 10:38:19 UTC 2023 on atb-devel-224

source3/winbindd/winbindd_list_users.c

index 7acc3f7d761f823fabdd110471734bfd23893d82..8630672c323e641f245e09ce04ee135abc94e450 100644 (file)
@@ -100,9 +100,15 @@ struct tevent_req *winbindd_list_users_send(TALLOC_CTX *mem_ctx,
 
        for (i=0; i<state->num_domains; i++) {
                struct winbindd_list_users_domstate *d = &state->domains[i];
-
-               d->subreq = wb_query_user_list_send(
-                       state->domains, ev, d->domain);
+               /*
+                * Use "state" as a talloc memory context since it has type
+                * "struct tevent_req". This is needed to make tevent call depth
+                * tracking working as expected.
+                * After calling wb_query_user_list_send(), re-parent back to
+                * "state->domains" to make TALLOC_FREE(state->domains) working.
+                */
+               d->subreq = wb_query_user_list_send(state, ev, d->domain);
+               d->subreq = talloc_reparent(state, state->domains, d->subreq);
                if (tevent_req_nomem(d->subreq, req)) {
                        TALLOC_FREE(state->domains);
                        return tevent_req_post(req, ev);