[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 11 Sep 2003 07:57:03 -0000
albertel Thu Sep 11 03:57:03 2003 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- yes if the other machine is down, it has a load of zero, this doesn't mean we should send the user over to it :-)
- I need to do a bit more testing with this to make sure it is all good
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.410 loncom/lonnet/perl/lonnet.pm:1.411
--- loncom/lonnet/perl/lonnet.pm:1.410 Wed Sep 10 11:53:16 2003
+++ loncom/lonnet/perl/lonnet.pm Thu Sep 11 03:57:03 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.410 2003/09/10 15:53:16 matthew Exp $
+# $Id: lonnet.pm,v 1.411 2003/09/11 07:57:03 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -436,15 +436,27 @@
my $lowestserver=$loadpercent > $userloadpercent?
$loadpercent : $userloadpercent;
foreach $tryserver (keys %spareid) {
- my $loadans=reply('load',$tryserver);
- my $userloadans=reply('userload',$tryserver);
- if ($userloadans !~ /\d/) { $userloadans=0; }
- my $answer=$loadans > $userloadans?
- $loadans : $userloadans;
- if (($answer =~ /\d/) && ($answer<$lowestserver)) {
- $spareserver="http://$hostname{$tryserver}";
- $lowestserver=$answer;
- }
+ my $loadans=reply('load',$tryserver);
+ my $userloadans=reply('userload',$tryserver);
+ if ($loadans !~ /\d/ && $userloadans !~ /\d/) {
+ next; #didn't get a number from the server
+ }
+ my $answer;
+ if ($loadans =~ /\d/) {
+ if ($userloadans =~ /\d/) {
+ #both are numbers, pick the bigger one
+ $answer=$loadans > $userloadans?
+ $loadans : $userloadans;
+ } else {
+ $answer = $loadans;
+ }
+ } else {
+ $answer = $userloadans;
+ }
+ if (($answer =~ /\d/) && ($answer<$lowestserver)) {
+ $spareserver="http://$hostname{$tryserver}";
+ $lowestserver=$answer;
+ }
}
return $spareserver;
}