lib/util/run_cmd: use a cleanup function instead of a destructor
authorRalph Boehme <slow@samba.org>
Fri, 29 Sep 2017 11:07:53 +0000 (13:07 +0200)
committerRalph Boehme <slow@samba.org>
Sat, 30 Sep 2017 10:14:56 +0000 (12:14 +0200)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13062

Pair-programmed-with: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph B√∂hme <slow@samba.org>
Autobuild-Date(master): Sat Sep 30 12:14:57 CEST 2017 on sn-devel-144

lib/util/util_runcmd.c

index b2f0d9fbc45e77a281ff7fefcda19a9718e1a938..42d84a895bf21aa11381ea1b1c3e5763d9123abe 100644 (file)
 #include "../lib/util/tfork.h"
 #include "../lib/util/sys_rw.h"
 
-static int samba_runcmd_state_destructor(struct samba_runcmd_state *state)
+static void samba_runcmd_cleanup_fn(struct tevent_req *req,
+                                   enum tevent_req_state req_state)
 {
+       struct samba_runcmd_state *state = tevent_req_data(
+               req, struct samba_runcmd_state);
+
        if (state->tfork != NULL) {
                tfork_destroy(&state->tfork);
        }
@@ -43,7 +47,6 @@ static int samba_runcmd_state_destructor(struct samba_runcmd_state *state)
                close(state->fd_stdin);
                state->fd_stdin = -1;
        }
-       return 0;
 }
 
 static void samba_runcmd_io_handler(struct tevent_context *ev,
@@ -140,7 +143,7 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx,
                smb_set_close_on_exec(state->fd_stderr);
                smb_set_close_on_exec(state->fd_status);
 
-               talloc_set_destructor(state, samba_runcmd_state_destructor);
+               tevent_req_set_cleanup_fn(req, samba_runcmd_cleanup_fn);
 
                state->fde_stdout = tevent_add_fd(ev, state,
                                                  state->fd_stdout,