Step one of traffic control, have SSL inform UDP process of current client count
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15876 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
1138ab87d4
commit
b9e587e703
@ -93,6 +93,8 @@ sub start {
|
||||
return 0;
|
||||
}
|
||||
elsif (defined($pid)) { #child process
|
||||
my $progname = \$0;
|
||||
$$progname = "xcatd: monitoring";
|
||||
my $localhostname=hostname();
|
||||
|
||||
if ($isMonServer) { #only start monitoring on monservers.
|
||||
|
@ -18,6 +18,8 @@ BEGIN
|
||||
}
|
||||
}
|
||||
|
||||
my $sslctl;
|
||||
my $udpctl;
|
||||
# if AIX - make sure we include perl 5.8.2 in INC path.
|
||||
# Needed to find perl dependencies shipped in deps tarball.
|
||||
if ($^O =~ /^aix/i) {
|
||||
@ -542,6 +544,7 @@ sleep 0.05;
|
||||
print $udppidfile $$;
|
||||
close($udppidfile);
|
||||
$select->add($socket);
|
||||
$select->add($sslctl);
|
||||
my $data;
|
||||
my $part;
|
||||
my $sport;
|
||||
@ -561,12 +564,28 @@ sleep 0.05;
|
||||
populate_site_hash();
|
||||
yield;
|
||||
}
|
||||
while ($select->can_read(0)) { #Pull all buffer data that can be pulled
|
||||
my @hdls;
|
||||
while (@hdls = $select->can_read(0)) { #Pull all buffer data that can be pulled
|
||||
my $hdl;
|
||||
foreach $hdl (@hdls) {
|
||||
if ($hdl == $socket) {
|
||||
$part = $socket->recv($data,1500);
|
||||
($sport,$client) = sockaddr_in($part);
|
||||
if ($sport < 1000) { #Only remember udp packets from privileged ports
|
||||
$packets{inet_ntoa($client)} = [$part,$data];
|
||||
}
|
||||
} elsif ($hdl == $sslctl) {
|
||||
my $msg;
|
||||
eval { $msg = fd_retrieve($sslctl); };
|
||||
if ($msg) {
|
||||
} else {
|
||||
$select->remove($hdl); close($hdl); #something went horribly wrong
|
||||
}
|
||||
|
||||
} else {
|
||||
print "Something is wrong in udp process (search xcatd for this string)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach my $pkey (keys %packets) {
|
||||
($sport,$client) = sockaddr_in($packets{$pkey}->[0]);
|
||||
@ -579,6 +598,7 @@ sleep 0.05;
|
||||
IO::Uncompress::Gunzip::gunzip(\$data,\$bigdata);
|
||||
$data = $bigdata
|
||||
}
|
||||
if ($data !~ /^<xcat/) { #xml format
|
||||
my $req = eval { XMLin($data, SuppressEmpty=>undef,ForceArray=>1) };
|
||||
if ($req and $req->{command} and ($req->{command}->[0] eq "findme")) {
|
||||
$req->{'_xcat_clienthost'}=gethostbyaddr($client,AF_INET);
|
||||
@ -602,6 +622,9 @@ sleep 0.05;
|
||||
xCAT::MsgUtils->message("S","xcatd: Skipping discovery from ".inet_ntoa($client)." because we either have no discovery plugins or the client address does not match an IP network that xCAT is managing");
|
||||
}
|
||||
}
|
||||
} else { # for *now*, we'll do a tiny YAML subset
|
||||
} # JSON maybe one day if important
|
||||
}
|
||||
if ($quit) { last; }
|
||||
while ($select->can_read(0)) { #grab any incoming requests during run
|
||||
$part = $socket->recv($data,1500);
|
||||
@ -695,6 +718,7 @@ if (defined $pid_init) {
|
||||
close($writepipe);
|
||||
%cmd_handlers = %{fd_retrieve($readpipe)};
|
||||
} else {
|
||||
$$progname = "xcatd: plugin initialization";
|
||||
scan_plugins($writepipe);
|
||||
exit(0);
|
||||
}
|
||||
@ -728,12 +752,15 @@ sub generic_reaper {
|
||||
}
|
||||
|
||||
sub ssl_reaper {
|
||||
my $numdone = 0;
|
||||
while (($CHILDPID=waitpid(-1,WNOHANG)) > 0) {
|
||||
if ($immediatechildren{$CHILDPID}) {
|
||||
delete $immediatechildren{$CHILDPID};
|
||||
$sslclients--;
|
||||
$numdone--;
|
||||
}
|
||||
$sslclients--;
|
||||
}
|
||||
store_fd({clientcountchange=>$numdone,sslclientcount=>$sslclients},$udpctl); #notify udp service of how many clients are active
|
||||
$SIG{CHLD} = \&ssl_reaper;
|
||||
}
|
||||
|
||||
@ -785,16 +812,24 @@ $SIG{TERM} = $SIG{INT} = sub {
|
||||
alarm(2);
|
||||
};
|
||||
|
||||
socketpair($sslctl, $udpctl,AF_UNIX,SOCK_STREAM,PF_UNSPEC);
|
||||
my $prevfh = select($udpctl);
|
||||
$|=1;
|
||||
select($sslctl);
|
||||
$|=1;
|
||||
select($prevfh);
|
||||
$pid_UDP = xCAT::Utils->xfork;
|
||||
if (! defined $pid_UDP) {
|
||||
xCAT::MsgUtils->message("S", "Unable to fork for UDP/TCP");
|
||||
die;
|
||||
}
|
||||
unless ($pid_UDP) {
|
||||
close($udpctl);
|
||||
$$progname="xcatd: UDP listener";
|
||||
do_udp_service;
|
||||
xexit(0);
|
||||
}
|
||||
close($sslctl);
|
||||
$pid_MON = xCAT::Utils->xfork;
|
||||
if (! defined $pid_MON) {
|
||||
xCAT::MsgUtils->message("S", "Unable to fork installmonitor");
|
||||
@ -802,6 +837,7 @@ if (! defined $pid_MON) {
|
||||
}
|
||||
unless ($pid_MON) {
|
||||
$$progname="xcatd: install monitor";
|
||||
close($udpctl);
|
||||
do_installm_service;
|
||||
xexit(0);
|
||||
}
|
||||
@ -942,6 +978,7 @@ until ($quit) {
|
||||
}
|
||||
|
||||
if ($child == 0) {
|
||||
close($udpctl);
|
||||
$SIG{TERM} = $SIG{INT} = {};
|
||||
$SIG{CHLD} = \&generic_reaper; #THROTTLE
|
||||
$listener->close;
|
||||
@ -1019,6 +1056,7 @@ if ($inet6support) {
|
||||
xexit(0);
|
||||
}
|
||||
$sslclients++; #THROTTLE
|
||||
store_fd({clientcountchange=>1,sslclientcount=>$sslclients},$udpctl); #notify udp service of how many clients are active
|
||||
$cnnection->close();
|
||||
}
|
||||
if (open($mainpidfile,"<","/var/run/xcat/mainservice.pid")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user