From 5ef9d65a80ad072d2a091f974c51db8fb15f05d4 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:58:14 -0300 Subject: [PATCH] refactor(xcat-core): the respawn policy was built above the use line that provides it xCAT::RespawnUtils::policy() was called near the top of the file, some twenty lines above the "use xCAT::RespawnUtils" that loads the module. It works, because use is compile-time and perl compiles the whole file before running any of it, so the import has already happened by the time that statement executes. But nothing at the call site says so. It reads as a plain ordering mistake, and it stops working the moment someone converts the import to require -- a routine thing to do to a daemon that loads this many modules -- with the failure being an undefined subroutine at startup. Move the declaration below the imports, next to the osver() call that already makes a runtime call to a use'd module there. The only constraint on where it can go is that ssl_reaper closes over $mon_respawn and so must be compiled after it is declared; the new position clears that by a thousand lines, and compiling under strict is what proves it, since a lexical declared after the sub would fail to compile rather than silently bind elsewhere. Pure relocation: the moved block is byte-identical and no behaviour changes. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-server/sbin/xcatd | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index b47b0ba8d..1b344c08b 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -30,17 +30,6 @@ my $udpctl; my $pid_UDP; my $pid_MON; -# Pacing for re-forking the install monitor; see the main service loop below. The pacing -# itself is pure arithmetic in xCAT::RespawnUtils -- a backoff with a ceiling but no end, -# so a held xcatiport costs one fork per ceiling interval instead of a fork storm, and the -# monitor is back within that bound once the port is free. Each function returns a NEW -# state, which is why the reaper can safely install one from inside the signal handler. -my $mon_respawn = xCAT::RespawnUtils::policy( - min_interval => $ENV{XCATD_MON_RESPAWN_MIN_INTERVAL}, - max_interval => $ENV{XCATD_MON_RESPAWN_MAX_INTERVAL}, - healthy => $ENV{XCATD_MON_RESPAWN_HEALTHY}, -); - my $numofnodes=0; # ----used for command log start--------- @@ -65,6 +54,18 @@ use xCAT::RespawnUtils; use xCAT::xcatd; use xCAT::CmdLog; use xCAT::State; + +# Pacing for re-forking the install monitor; see the main service loop below. The pacing +# itself is pure arithmetic in xCAT::RespawnUtils -- a backoff with a ceiling but no end, +# so a held xcatiport costs one fork per ceiling interval instead of a fork storm, and the +# monitor is back within that bound once the port is free. Each function returns a NEW +# state, which is why the reaper can safely install one from inside the signal handler. +my $mon_respawn = xCAT::RespawnUtils::policy( + min_interval => $ENV{XCATD_MON_RESPAWN_MIN_INTERVAL}, + max_interval => $ENV{XCATD_MON_RESPAWN_MAX_INTERVAL}, + healthy => $ENV{XCATD_MON_RESPAWN_HEALTHY}, +); + my $os = xCAT::Utils->osver(); my $arch = `uname -p`;