From 0c0ec38b6e134f0abd4078ad247d0adf2d74b07a Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 20 Mar 2008 14:19:12 +0000 Subject: [PATCH] -Change psh to tend to group readily available output together -Prevent psh from uselessly looping on an impossible condition (checking for new data from children when they haven't gotten to run( -Change buffer flushes to happen less frequently git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@851 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client-2.0/bin/psh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/xCAT-client-2.0/bin/psh b/xCAT-client-2.0/bin/psh index ba6cf3177..44e419940 100755 --- a/xCAT-client-2.0/bin/psh +++ b/xCAT-client-2.0/bin/psh @@ -14,6 +14,7 @@ use IO::Select; use xCAT::Utils; use Getopt::Long; use POSIX qw(:signal_h :errno_h :sys_wait_h); +use Thread qw(yield); my $interface; my $username; my $help; @@ -109,16 +110,21 @@ sub processoutput { #This way, one arbiter handles output, no interrupting my $rc = @readyins; my $readyh; foreach $readyh (@readyins) { - my $line = <$readyh>; - unless ($line) { - $inputs->remove($readyh); - close($readyh); - next; - } - chomp($line); - print $nodehdl{$readyh}.": ".$line."\n"; - IO::Handle::flush(stdout); + my $cursel = new IO::Select; + $cursel->add($readyh); + while ($cursel->can_read(0)) { + my $line = <$readyh>; + unless ($line) { + $inputs->remove($readyh); + close($readyh); + next; + } + chomp($line); + print $nodehdl{$readyh}.": ".$line."\n"; + } } + IO::Handle::flush(stdout); + yield; #Explicitly give all children a chance to refill any buffers return $rc; } sub sshnode {