-Fix erroneous db worker process cloning

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5231 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2010-02-17 22:19:39 +00:00
parent 1921256e4c
commit c0c7ff2c54

View File

@ -70,6 +70,7 @@ my $dbworkersocket;
my $dbsockpath = "/tmp/xcat/dbworker.sock";
my $exitdbthread;
my $dbobjsforhandle;
my $intendedpid;
sub dbc_call {
@ -150,6 +151,7 @@ sub init_dbworker {
die "Error spawining database worker";
}
unless ($dbworkerpid) {
$intendedpid = $$;
$SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) {}}; #avoid zombies from notification framework
#This process is the database worker, it's job is to manage database queries to reduce required handles and to permit cross-process caching
$0 = "xcatd: DB Access";
@ -200,6 +202,9 @@ sub init_dbworker {
my $err=$@;
xCAT::MsgUtils->message("S","xcatd: possible BUG encountered by xCAT DB worker ".$err);
}
if ($intendedpid != $$) { #avoid redundant fork
exit(0);
}
}
close($dbworkersocket);
unlink($dbsockpath);