-Give up after 30 seconds of starvation

-Actually sleep in the retry loop rather than being a busy loop


git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6992 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2010-08-06 12:54:41 +00:00
parent 4da5599717
commit e82e3f5f8b

View File

@ -38,6 +38,7 @@ use Storable qw/freeze thaw/;
use IO::Socket;
use Data::Dumper;
use POSIX qw/WNOHANG/;
use Time::HiRes qw (sleep);
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
@ -92,9 +93,11 @@ sub dbc_submit {
my $data = freeze($request);
$data.= "\nENDOFFREEZEQFVyo4Cj6Q0v\n";
my $clisock;
while(!($clisock = IO::Socket::UNIX->new(Peer => $dbsockpath, Type => SOCK_STREAM, Timeout => 120) ) ) {
my $tries=300;
while($tries and !($clisock = IO::Socket::UNIX->new(Peer => $dbsockpath, Type => SOCK_STREAM, Timeout => 120) ) ) {
#print "waiting for clisock to be available\n";
sleep 0.1;
$tries--;
}
unless ($clisock) {
use Carp qw/cluck/;