From: Shachar Sharon Date: Tue, 5 May 2026 10:17:18 +0000 (+0300) Subject: ctdb-server: Cleanup child resources via local helper X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67f139ad28c6a771bac488b09d52dda81f3ffe81;p=thirdparty%2Fsamba.git ctdb-server: Cleanup child resources via local helper 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 Reviewed-by: Martin Schwenke Reviewed-by: Anoop C S Reviewed-by: Vinit Agnihotri Reviewed-by: Avan Thakkar Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Wed May 6 05:28:48 UTC 2026 on atb-devel-224 --- diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c index ff13a59980b..78ee39015e6 100644 --- a/ctdb/server/ctdb_call.c +++ b/ctdb/server/ctdb_call.c @@ -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);