[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
www
lon-capa-cvs@mail.lon-capa.org
Fri, 23 Feb 2007 15:49:24 -0000
www Fri Feb 23 10:49:24 2007 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
Faster reconnects after machine has been offline, eliminate legacy code
in reconlonc
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.835 loncom/lonnet/perl/lonnet.pm:1.836
--- loncom/lonnet/perl/lonnet.pm:1.835 Thu Feb 22 19:23:46 2007
+++ loncom/lonnet/perl/lonnet.pm Fri Feb 23 10:49:23 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.835 2007/02/23 00:23:46 albertel Exp $
+# $Id: lonnet.pm,v 1.836 2007/02/23 15:49:23 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -201,8 +201,7 @@
# ----------------------------------------------------------- Send USR1 to lonc
sub reconlonc {
- my $peerfile=shift;
- &logthis("Trying to reconnect for $peerfile");
+ &logthis("Trying to reconnect lonc");
my $loncfile="$perlvar{'lonDaemons'}/logs/lonc.pid";
if (open(my $fh,"<$loncfile")) {
my $loncpid=<$fh>;
@@ -211,19 +210,13 @@
&logthis("lonc at pid $loncpid responding, sending USR1");
kill USR1 => $loncpid;
sleep 1;
- if (-e "$peerfile") { return; }
- &logthis("$peerfile still not there, give it another try");
- sleep 5;
- if (-e "$peerfile") { return; }
- &logthis(
- "<font color=\"blue\">WARNING: $peerfile still not there, giving up</font>");
- } else {
+ } else {
&logthis(
"<font color=\"blue\">WARNING:".
" lonc at pid $loncpid not responding, giving up</font>");
}
} else {
- &logthis('<font color="blue">WARNING: lonc not running, giving up</font>');
+ &logthis('<font color="blue">WARNING: lonc not running, giving up</font>');
}
}
@@ -615,9 +608,15 @@
my ($uname,$upass,$udom)=@_;
$upass=&escape($upass);
$uname= &LONCAPA::clean_username($uname);
- my $uhome=&homeserver($uname,$udom);
- if (!$uhome) {
- &logthis("User $uname at $udom is unknown in authenticate");
+ my $uhome=&homeserver($uname,$udom,1);
+ if ((!$uhome) || ($uhome eq 'no_host')) {
+# Maybe the machine was offline and only re-appeared again recently?
+ &reconlonc();
+# One more
+ my $uhome=&homeserver($uname,$udom,1);
+ if ((!$uhome) || ($uhome eq 'no_host')) {
+ &logthis("User $uname at $udom is unknown in authenticate");
+ }
return 'no_host';
}
my $answer=reply("encrypt:auth:$udom:$uname:$upass",$uhome);
@@ -647,7 +646,8 @@
exists($badServerCache{$tryserver}));
if ($hostdom{$tryserver} eq $udom) {
my $answer=reply("home:$udom:$uname",$tryserver);
- if ($answer eq 'found') {
+ if ($answer eq 'found') {
+ delete($badServerCache{$tryserver});
return $homecache{$index}=$tryserver;
} elsif ($answer eq 'no_host') {
$badServerCache{$tryserver}=1;