mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-18 20:30:56 +00:00
Fix code error to generate the right socket file name based on the caller PID (#5257)
This commit is contained in:
@ -25,8 +25,8 @@ use xCAT_monitoring::monitorctrl;
|
||||
use xCAT::TableUtils;
|
||||
|
||||
my $LOCK_DIR = "/var/lock/xcat/";
|
||||
my $LOCK_PATH = "/var/lock/xcat/agent-$$.lock";
|
||||
my $AGENT_SOCK_PATH = "/var/run/xcat/agent-$$.sock";
|
||||
my $LOCK_PATH = "/var/lock/xcat/agent.lock";
|
||||
my $AGENT_SOCK_PATH = "/var/run/xcat/agent.sock";
|
||||
my $PYTHON_LOG_PATH = "/var/log/xcat/agent.log";
|
||||
my $PYTHON_AGENT_FILE = "/opt/xcat/lib/python/agent/agent.py";
|
||||
my $MSG_TYPE = "message";
|
||||
@ -62,8 +62,15 @@ sub send_request {
|
||||
# if lock is released unexpectedly, python side would aware of the error after
|
||||
# getting this lock
|
||||
sub acquire_lock {
|
||||
my $ppid = shift;
|
||||
$ppid = shift if (($ppid) && ($ppid =~ /OPENBMC/));
|
||||
|
||||
mkpath($LOCK_DIR);
|
||||
# always create a new lock file
|
||||
if ($ppid) {
|
||||
$LOCK_PATH = "$LOCK_PATH.$ppid";
|
||||
$AGENT_SOCK_PATH = "$AGENT_SOCK_PATH.$ppid";
|
||||
}
|
||||
unlink($LOCK_PATH);
|
||||
open($lock_fd, ">>", $LOCK_PATH) or return undef;
|
||||
flock($lock_fd, LOCK_EX) or return undef;
|
||||
@ -82,7 +89,10 @@ sub python_agent_reaper {
|
||||
}
|
||||
sub start_python_agent {
|
||||
|
||||
if (!defined(acquire_lock())) {
|
||||
my $ppid = shift;
|
||||
$ppid = shift if (($ppid) && ($ppid =~ /OPENBMC/));
|
||||
|
||||
if (!defined(acquire_lock($ppid))) {
|
||||
xCAT::MsgUtils->message("S", "start_python_agent() Error: Failed to acquire lock");
|
||||
return undef;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ sub process_request {
|
||||
return unless(%node_info);
|
||||
|
||||
# If we can't start the python agent, exit immediately
|
||||
my $pid = xCAT::OPENBMC::start_python_agent();
|
||||
my $pid = xCAT::OPENBMC::start_python_agent($$);
|
||||
if (!defined($pid)) {
|
||||
xCAT::MsgUtils->message("E", { data => ["Failed to start the xCAT Python agent. Check /var/log/xcat/cluster.log for more information."] }, $callback);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user