From e82e3f5f8b1e51dd57a60e1e707e2c023d9aaab2 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 6 Aug 2010 12:54:41 +0000 Subject: [PATCH] -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 --- perl-xCAT/xCAT/Table.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 110fdbacf..b23c09c88 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -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/;