--- loncom/loncnew 2003/12/11 23:18:37 1.34 +++ loncom/loncnew 2004/01/05 09:29:36 1.38 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # lonc maintains the connections to remote computers # -# $Id: loncnew,v 1.34 2003/12/11 23:18:37 albertel Exp $ +# $Id: loncnew,v 1.38 2004/01/05 09:29:36 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,12 +35,12 @@ # - Add ability to create/negotiate lond connections (done). # - Add general logic for dispatching requests and timeouts. (done). # - Add support for the lonc/lond requests. (done). -# - Add logging/status monitoring. -# - Add Signal handling - HUP restarts. USR1 status report. +# - Add logging/status monitoring. (done) +# - Add Signal handling - HUP restarts. USR1 status report. (done) # - Add Configuration file I/O (done). -# - Add management/status request interface. +# - Add management/status request interface. (done) # - Add deferred request capability. (done) -# - Detect transmission timeouts. +# - Detect transmission timeouts. (done) # use strict; @@ -210,7 +210,6 @@ sub GetPeername { return $peerfile; } } -#----------------------------- Timer management ------------------------ =pod =head2 Debug @@ -262,11 +261,14 @@ sub ShowStatus { =cut sub SocketTimeout { my $Socket = shift; - + Log("WARNING", "A socket timeout was detected"); + Debug(0, " SocketTimeout called: "); + $Socket->Dump(); KillSocket($Socket); # A transaction timeout also counts as # a connection failure: $ConnectionRetriesLeft--; } +#----------------------------- Timer management ------------------------ =pod @@ -301,14 +303,10 @@ sub Tick { # # For each inflight transaction, tick down its timeout counter. # - foreach my $item (keys %ActiveTransactions) { - my $Socket = $ActiveTransactions{$item}->getServer(); - $Socket->Tick(); - } + foreach my $item (keys %ActiveConnections) { my $State = $ActiveConnections{$item}->data->GetState(); - if ($State ne 'Idle' && $State ne 'SendingRequest' && - $State ne 'ReceivingReply') { + if ($State ne 'Idle') { Debug(5,"Ticking Socket $State $item"); $ActiveConnections{$item}->data->Tick(); } @@ -659,9 +657,9 @@ sub KillSocket { } if(exists($ActiveConnections{$Socket})) { delete($ActiveConnections{$Socket}); + $ConnectionCount--; + if ($ConnectionCount < 0) { $ConnectionCount = 0; } } - $ConnectionCount--; - # If the connection count has gone to zero and there is work in the # work queue, the work all gets failed with con_lost. # @@ -1346,6 +1344,20 @@ sub ChildStatus { my $fh = IO::File->new(">>$docdir/lon-status/loncstatus.txt"); print $fh $$."\t".$RemoteHost."\t".$Status."\t". $RecentLogEntry."\n"; + # + # Write out information about each of the connections: + # + print $fh "Active connection statuses: \n"; + my $i = 1; + print STDERR "================================= Socket Status Dump:\n"; + foreach my $item (keys %ActiveConnections) { + my $Socket = $ActiveConnections{$item}->data; + my $state = $Socket->GetState(); + print $fh "Connection $i State: $state\n"; + print STDERR "---------------------- Connection $i \n"; + $Socket->Dump(); + $i++; + } $ConnectionRetriesLeft = $ConnectionRetries; }