version 1.549, 2004/10/05 11:24:34
|
version 1.550, 2004/10/06 09:48:39
|
Line 52 use Apache::lonlocal;
|
Line 52 use Apache::lonlocal;
|
use Storable qw(lock_store lock_nstore lock_retrieve freeze thaw); |
use Storable qw(lock_store lock_nstore lock_retrieve freeze thaw); |
use Time::HiRes qw( gettimeofday tv_interval ); |
use Time::HiRes qw( gettimeofday tv_interval ); |
my $readit; |
my $readit; |
|
my $max_connection_retries = 10; # Or some such value. |
|
|
=pod |
=pod |
|
|
Line 126 sub subreply {
|
Line 127 sub subreply {
|
sleep(1); |
sleep(1); |
} |
} |
# At this point, either a loncnew parent is listening or an old lonc |
# At this point, either a loncnew parent is listening or an old lonc |
# or loncnew child is listening so we can connect. |
# or loncnew child is listening so we can connect or everything's dead. |
# |
# |
my $client=IO::Socket::UNIX->new(Peer =>"$peerfile", |
# We'll give the connection a few tries before abandoning it. If |
Type => SOCK_STREAM, |
# connection is not possible, we'll con_lost back to the client. |
Timeout => 10) |
# |
or return "con_lost"; |
my $client; |
print $client "$cmd\n"; |
for (my $retries = 0; $retries < $max_connection_retries; $retries++) { |
my $answer=<$client>; |
$client=IO::Socket::UNIX->new(Peer =>"$peerfile", |
if (!$answer) { $answer="con_lost"; } |
Type => SOCK_STREAM, |
chomp($answer); |
Timeout => 10); |
|
if($client) { |
|
last; # Connected! |
|
} |
|
sleep(1); # Try again later if failed connection. |
|
} |
|
my $answer; |
|
if ($client) { |
|
print $client "$cmd\n"; |
|
$answer=<$client>; |
|
if (!$answer) { $answer="con_lost"; } |
|
chomp($answer); |
|
} else { |
|
$answer = 'con_lost'; # Failed connection. |
|
} |
return $answer; |
return $answer; |
} |
} |
|
|