--- loncom/loncnew 2004/07/02 09:28:14 1.50 +++ loncom/loncnew 2004/08/26 12:35:10 1.51 @@ -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 $ConnectionRetriesLeft=2; # Number of 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 @@ sub Tick { 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 @@ Trigger disconnections of idle sockets. =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 @@ sub QueueTransaction { 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 @@ sub ChildProcess { cb => \&ToggleDebug, data => "INT"); - SetupTimer(); + SetupTimer($LongTickLength); SetupLoncListener();