From 3cfc361a870754231320c78ae2b48b17511a8e5b Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 13 Oct 2009 02:05:18 +0000 Subject: [PATCH] Fixed 2872962 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4359 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/PPC.pm | 54 +++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 9d1bf5071..85d61ead9 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -119,6 +119,8 @@ sub process_command { if ( exists( $request->{verbose} )) { $start = Time::HiRes::gettimeofday(); } + + $request->{maxssh} = int($request->{maxssh}/2); ####################################### # Group nodes based on command ####################################### @@ -362,6 +364,57 @@ sub process_command { } $callback->({data=>["Unreachable Nodes:"]}); $callback->({data=>["$unreachable_nodes\n"]}); + } elsif ( $request->{command} =~ /^rpower$/ ) { + my $hw; + my $sessions; + my $pid_owner; + my $remain_node = $nodes; + + while ( scalar($remain_node) ) { + $remain_node = (); + foreach my $hash ( @$nodes ) { + $SIG{CHLD} = sub { my $pid = 0; while (($pid = waitpid(-1, WNOHANG)) > 0) { $hw->{$pid_owner->{$pid}}--; $children--; } }; + + while ( $children >= $request->{ppcmaxp} ) { + my $handlednodes={}; + child_response( $callback, $fds, $handlednodes); + + #update the node status to the nodelist.status table + if ($check) { + updateNodeStatus($handlednodes, \@allerrornodes); + } + + Time::HiRes::sleep(0.1); + } + if ( $hw->{@$hash[0]} >= $request->{maxssh} ) { + my $handlednodes={}; + child_response( $callback, $fds, $handlednodes); + + #update the node status to the nodelist.status table + if ($check) { + updateNodeStatus($handlednodes, \@allerrornodes); + } + + Time::HiRes::sleep(0.1); + push( @$remain_node, [@$hash[0], @$hash[1]] ); + next; + } + + my ($pipe,$pid) = fork_cmd( @$hash[0], @$hash[1], $request ); + + if ($pid) { + $pid_owner->{$pid} = @$hash[0]; + $hw->{@$hash[0]}++; + } + + if ( $pipe ) { + $fds->add( $pipe ); + $children++; + } + } + + $nodes = $remain_node; + } } else { $SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) { $children--; } }; my $hw; @@ -391,7 +444,6 @@ sub process_command { } $hw = @$_[0]; - Time::HiRes::sleep(0.5); my ($pipe) = fork_cmd( @$_[0], @$_[1], $request ); if ( $pipe ) { $fds->add( $pipe );