-Use yield in child process data collection loops to avoid cycling needlessly, what was happing implicitly with sleep, the part that mattered

-Copy hardeths redundantly, still need to pick one definitive place and go with that


git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@738 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2008-03-10 15:36:44 +00:00
parent 1f09bc78d8
commit 129af8ee3e
4 changed files with 16 additions and 2 deletions

View File

@ -3,6 +3,7 @@
package xCAT_plugin::blade;
#use Net::SNMP qw(:snmp INTEGER);
use xCAT::Table;
use Thread qw(yield);
use xCAT::Utils;
use IO::Socket;
use SNMP;
@ -1101,6 +1102,7 @@ sub forward_data {
close($rfh);
}
}
yield; #Try to avoid useless iterations as much as possible
return $rc;
}

View File

@ -8,6 +8,7 @@ package xCAT_plugin::ipmi;
use Storable qw(store_fd retrieve_fd thaw freeze);
use xCAT::Utils;
use Thread qw(yield);
require Exporter;
@ISA = qw(Exporter);
@ -4541,6 +4542,7 @@ sub forward_data { #unserialize data from pipe, chunk at a time, use magic to de
close($rfh);
}
}
yield; #Avoid useless loop iterations by giving children a chance to fill pipes
return $rc;
}

View File

@ -9,6 +9,7 @@ use Storable qw(freeze thaw);
use xCAT::Utils;
use File::Path;
use Time::HiRes qw(sleep);
use Thread qw(yield);
use xCAT::Client submit_request;
use IO::Socket::SSL;
@ -645,7 +646,7 @@ sub relay_dispatch {
close($rin);
}
}
sleep (0.01); #Again, try not to overwhelm the system
yield; #At this point, explicitly yield to other processes. If children will have more data, this process would otherwise uselessly loop on data that never will be. If children are all done, still no harm in waiting a short bit for a timeslice to come back
return scalar(@ready_ins);
}
@ -914,7 +915,7 @@ sub relay_fds { #Relays file descriptors from pipes to children to the SSL socke
close($rfh);
}
}
sleep (0.01); #This gets called in a loop a lot, this takes the edge off
yield; #Give other processes, including children, explicit control, to avoid uselessly aggressive looping
return $rc;
}

View File

@ -0,0 +1,9 @@
for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do
IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'`
NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'`
sed -i s/BOOTPROTO=dhcp/BOOTPROTO=none/ /etc/sysconfig/network-scripts/ifcfg-$nic
echo IPADDR=$IPADDR >> /etc/sysconfig/network-scripts/ifcfg-$nic
echo NETMASK=$NETMASK >> /etc/sysconfig/network-scripts/ifcfg-$nic
done
sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network