]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-server: Cleanup child resources via local helper
authorShachar Sharon <ssharon@redhat.com>
Tue, 5 May 2026 10:17:18 +0000 (13:17 +0300)
committerMartin Schwenke <martins@samba.org>
Wed, 6 May 2026 05:28:48 +0000 (05:28 +0000)
Define 'revokechild_finish' as resource cleanup helper. Call it either
via destructor (normal case) or upon allocation failure.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16068

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: Avan Thakkar <athakkar@redhat.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed May  6 05:28:48 UTC 2026 on atb-devel-224

ctdb/server/ctdb_call.c

index ff13a59980b5e38a8ba5e62576315e8eff0e9d98..78ee39015e61e3c2a08b73314b2fbf1ff56daa68 100644 (file)
@@ -1635,6 +1635,17 @@ static int deferred_call_destructor(struct revokechild_deferred_call *dcall)
        return 0;
 }
 
+static void revokechild_finish(struct revokechild_handle *rev_hdl)
+{
+       if (rev_hdl->fd[0] != -1) {
+               close(rev_hdl->fd[0]);
+       }
+       if (rev_hdl->fd[1] != -1) {
+               close(rev_hdl->fd[1]);
+       }
+       ctdb_kill(rev_hdl->ctdb, rev_hdl->child, SIGKILL);
+}
+
 static int revokechild_destructor(struct revokechild_handle *rev_hdl)
 {
        struct revokechild_deferred_call *now_list = NULL;
@@ -1644,13 +1655,7 @@ static int revokechild_destructor(struct revokechild_handle *rev_hdl)
                talloc_free(rev_hdl->fde);
        }
 
-       if (rev_hdl->fd[0] != -1) {
-               close(rev_hdl->fd[0]);
-       }
-       if (rev_hdl->fd[1] != -1) {
-               close(rev_hdl->fd[1]);
-       }
-       ctdb_kill(rev_hdl->ctdb, rev_hdl->child, SIGKILL);
+       revokechild_finish(rev_hdl);
 
        DLIST_REMOVE(rev_hdl->ctdb_db->revokechild_active, rev_hdl);
 
@@ -1958,6 +1963,7 @@ child_finished:
 
        if (rev_hdl->fde == NULL) {
                D_ERR("Failed to set up fd event for revokechild process\n");
+               revokechild_finish(rev_hdl);
                goto err_out;
        }
        tevent_fd_set_auto_close(rev_hdl->fde);