mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-05 04:27:55 +00:00
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>
This commit is contained in:
+12
-11
@@ -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`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user