[LON-CAPA-cvs] cvs: loncom / loncnew
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 26 Aug 2004 12:35:10 -0000
albertel Thu Aug 26 08:35:10 2004 EDT
Modified files:
/loncom loncnew
Log:
- Decrease Tick length on Idle servers
Index: loncom/loncnew
diff -u loncom/loncnew:1.50 loncom/loncnew:1.51
--- loncom/loncnew:1.50 Fri Jul 2 05:28:14 2004
+++ loncom/loncnew Thu Aug 26 08:35:10 2004
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# lonc maintains the connections to remote computers
#
-# $Id: loncnew,v 1.50 2004/07/02 09:28:14 albertel Exp $
+# $Id: loncnew,v 1.51 2004/08/26 12:35:10 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -105,6 +105,10 @@
my $LondVersion = "unknown"; # Version of lond we talk with.
my $KeyMode = ""; # e.g. ssl, local, insecure from last connect.
+my $LongTickLength = 10000000; #Tick Frequency when Idle
+my $ShortTickLength = 1; #Tick Frequency when Active (many places in
+ # the code assume this is one)
+my $TickLength = $ShortTickLength;#number of seconds to wait until ticking
#
# The hash below gives the HTML format for log messages
# given a severity.
@@ -303,10 +307,13 @@
if($IdleConnections->Count() &&
($WorkQueue->Count() == 0)) { # Idle connections and nothing to do?
- $IdleSeconds++;
+ $IdleSeconds+=$TickLength;
if($IdleSeconds > $IdleTimeout) { # Prune a connection...
my $Socket = $IdleConnections->pop();
KillSocket($Socket);
+ if ($IdleConnections->Count() == 0) {
+ &SetupTimer($LongTickLength);
+ }
}
} else {
$IdleSeconds = 0; # Reset idle count if not idle.
@@ -370,9 +377,13 @@
=cut
+my $timer;
sub SetupTimer {
- Debug(6, "SetupTimer");
- Event->timer(interval => 1, cb => \&Tick );
+ my ($newLength)=@_;
+ Debug(6, "SetupTimer $TickLength->$newLength");
+ $TickLength=$newLength;
+ if ($timer) { $timer->cancel; }
+ $timer=Event->timer(interval => $TickLength, cb => \&Tick );
}
=pod
@@ -1232,6 +1243,7 @@
EmptyQueue(); # Fail transactions, can't make connection.
CloseAllLondConnections; # Should all be closed but...
}
+ &SetupTimer($ShortTickLength);
} else {
ShowStatus(GetServerHost()." >>> DEAD !!!! <<<");
EmptyQueue(); # It's worse than that ... he's dead Jim.
@@ -1521,7 +1533,7 @@
cb => \&ToggleDebug,
data => "INT");
- SetupTimer();
+ SetupTimer($LongTickLength);
SetupLoncListener();