--- loncom/Attic/lonc 2003/07/23 16:52:30 1.51 +++ loncom/Attic/lonc 2003/10/24 16:36:14 1.56 @@ -5,7 +5,7 @@ # provides persistent TCP connections to the other servers in the network # through multiplexed domain sockets # -# $Id: lonc,v 1.51 2003/07/23 16:52:30 bowersj2 Exp $ +# $Id: lonc,v 1.56 2003/10/24 16:36:14 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -124,7 +124,7 @@ close(CONFIG); %childatt = (); # number of attempts to start server # for ID -$childmaxattempts=5; +$childmaxattempts=15; # ---------------------------------------------------- Fork once and dissociate &status("Fork and dissociate"); @@ -361,13 +361,17 @@ while (1) { # accept a new connection &status("Accept new connection: $conserver"); $client = $server->accept(); - if($DEBUG) { - &logthis("New client fd = ".$client->fileno."\n"); + if (!$client) { + &logthis("Got stupid nonexisent client on ".$server->fileno." $conserver \n"); + } else { + if($DEBUG) { + &logthis("New client fd = ".$client->fileno."\n"); + } + $servers{$client->fileno} = $client; + nonblock($client); + $client->sockopt(SO_KEEPALIVE, 1); # Enable monitoring of + # connection liveness. } - $servers{$client->fileno} = $client; - nonblock($client); - $client->sockopt(SO_KEEPALIVE, 1);# Enable monitoring of - # connection liveness. } HandleInput($infdset, \%servers, \%inbuffer, \%outbuffer, \%ready); HandleOutput($outfdset, \%servers, \%outbuffer, \%inbuffer, @@ -638,7 +642,7 @@ sub handle { $request="enc:$cmdlength:$encrequest"; } # --------------------------------------------------------------- Main exchange - $answer = londtransaction($remotesock, $request, 300); + $answer = londtransaction($remotesock, $request, 60); if($DEBUG) { &logthis(" Request data exchange complete"); @@ -707,7 +711,7 @@ sub openremote { my $st=120+int(rand(240)); # Sleep before opening: unless ( - $remotesock = IO::Socket::INET->new(PeerAddr => $hostip{$conserver}, + $remotesock = IO::Socket::INET->new(PeerAddr => $hostname{$conserver}, PeerPort => $perlvar{'londPort'}, Proto => "tcp", Type => SOCK_STREAM) @@ -759,8 +763,7 @@ sub openremote { sleep 5; &status("Ponging $conserver"); - print $remotesock "pong\n"; - $answer=<$remotesock>; + $answer= londtransaction($remotesock,"pong",60); chomp($answer); if ($answer!~/^$conserver/) { &logthis("Pong reply: >$answer<"); @@ -768,8 +771,7 @@ sub openremote { # ----------------------------------------------------------- Initialize cipher &status("Initialize cipher"); - print $remotesock "ekey\n"; - my $buildkey=<$remotesock>; + my $buildkey=londtransaction($remotesock,"ekey",60); my $key=$conserver.$perlvar{'lonHostID'}; $key=~tr/a-z/A-Z/; $key=~tr/G-P/0-9/; @@ -990,12 +992,12 @@ sub londtransaction { alarm(0); }; } else { - &logthis("lonc - suiciding on send Timeout"); - die("lonc - suiciding on send Timeout"); + &logthis("lonc - $conserver - suiciding on send Timeout"); + die("lonc - $conserver - suiciding on send Timeout"); } if ($@ =~ /timeout/) { - &logthis("lonc - suiciding on read Timeout"); - die("lonc - suiciding on read Timeout"); + &logthis("lonc - $conserver - suiciding on read Timeout"); + die("lonc - $conserver - suiciding on read Timeout"); } # # Restore the initial sigmask set. @@ -1151,12 +1153,12 @@ Learner B solves a problem on server B's Home Server, so this information gets forwarded to B, where the records of H are updated. -=head2 lond, lonc, lonnet +=head2 lond, lonc, and lonnet =begin latex \begin{figure} -\includegraphics[width=0.75\paperwidth,keepaspectratio]{LONCAPA_Network_Diagram2} +\includegraphics[width=0.65\paperwidth,keepaspectratio]{LONCAPA_Network_Diagram2} \caption{\label{Overview_Of_Network_Communication}Overview of Network Communication} \end{figure} @@ -1428,9 +1430,9 @@ be copied over using the same mechanism B, which represents steps Steps B through B in the replication figure. -=head2 Load Balancing X +=head2 Load Balancing -C provides a function to query the server's current loadavg. As +XC provides a function to query the server's current loadavg. As a configuration parameter, one can determine the value of loadavg, which is to be considered 100%, for example, 2.00.