--- loncom/lond 2007/03/01 17:51:44 1.361 +++ loncom/lond 2007/03/28 20:28:29 1.364 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.361 2007/03/01 17:51:44 raeburn Exp $ +# $Id: lond,v 1.364 2007/03/28 20:28:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,7 +59,7 @@ my $DEBUG = 0; # Non zero to ena my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.361 $'; #' stupid emacs +my $VERSION='$Revision: 1.364 $'; #' stupid emacs my $remoteVERSION; my $currenthostid="default"; my $currentdomainid; @@ -1268,6 +1268,7 @@ sub du_handler { my $code=sub { if ($_=~/\.\d+\./) { return;} if ($_=~/\.meta$/) { return;} + if (-d $_) { return;} $total_size+=(stat($_))[7]; }; chdir($ududir); @@ -5308,15 +5309,36 @@ sub reconlonc { } } -# -------------------------------------------------- Non-critical communication +sub create_connection { + my ($hostname,$lonid) = @_; + my $client=IO::Socket::UNIX->new(Peer => $perlvar{'lonSockCreate'}, + Type => SOCK_STREAM, + Timeout => 10); + return 0 if (!$client); + print $client ("$hostname:$lonid\n"); + my $result = <$client>; + chomp($result); + return 1 if ($result eq 'done'); + return 0; +} +# -------------------------------------------------- Non-critical communication +my $max_connection_retries = 10; sub subreply { my ($cmd,$server)=@_; my $peerfile="$perlvar{'lonSockDir'}/".$hostname{$server}; - my $sclient=IO::Socket::UNIX->new(Peer =>"$peerfile", - Type => SOCK_STREAM, - Timeout => 10) - or return "con_lost"; + my $sclient; + for (my $retries = 0; $retries < $max_connection_retries; $retries++) { + $sclient=IO::Socket::UNIX->new(Peer =>"$peerfile", + Type => SOCK_STREAM, + Timeout => 10); + if($sclient) { + last; # Connected! + } else { + &create_connection($hostname{$server},$server); + } + sleep(1); # Try again later if failed connection. + } print $sclient "sethost:$server:$cmd\n"; my $answer=<$sclient>; chomp($answer);