[LON-CAPA-cvs] cvs: loncom / loncnew lond /lonnet/perl lonnet.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Mon, 18 Jun 2007 22:49:58 -0000


albertel		Mon Jun 18 18:49:58 2007 EDT

  Modified files:              
    /loncom	loncnew lond 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - when doing reconnects, be more targeted, just reset the retries on the
    one loncnew child (if it even exists)
  
  
  
Index: loncom/loncnew
diff -u loncom/loncnew:1.86 loncom/loncnew:1.87
--- loncom/loncnew:1.86	Tue Jun 12 23:05:54 2007
+++ loncom/loncnew	Mon Jun 18 18:49:52 2007
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # lonc maintains the connections to remote computers
 #
-# $Id: loncnew,v 1.86 2007/06/13 03:05:54 albertel Exp $
+# $Id: loncnew,v 1.87 2007/06/18 22:49:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1383,14 +1383,23 @@
     $data = $data.$thisread;	# Append new data.
     $watcher->data($data);
     if($data =~ /\n$/) {	# Request entirely read.
-	if($data eq "close_connection_exit\n") {
+	if ($data eq "close_connection_exit\n") {
 	    Log("CRITICAL",
 		"Request Close Connection ... exiting");
 	    CloseAllLondConnections();
 	    exit;
+	} elsif ($data eq "reset_retries\n") {
+	    Log("INFO", "Resetting Connection Retries.");
+	    $ConnectionRetriesLeft = $ConnectionRetries;
+	    &UpdateStatus();
+	    my $Transaction = LondTransaction->new($data);
+	    $Transaction->SetClient($socket);
+	    StartClientReply($Transaction, "ok\n");
+	    $watcher->cancel();
+	    return;
 	}
 	Debug(8, "Complete transaction received: ".$data);
-	if($LogTransactions) {
+	if ($LogTransactions) {
 	    Log("SUCCESS", "Transaction: '$data'"); # Transaction has \n.
 	}
 	my $Transaction = LondTransaction->new($data);
@@ -1898,7 +1907,7 @@
 
 sub parent_clean_up {
     my ($loncapa_host) = @_;
-    Debug(-1, "parent_clean_up: $loncapa_host");
+    Debug(1, "parent_clean_up: $loncapa_host");
 
     my $socket_file = &GetLoncSocketPath($loncapa_host);
     unlink($socket_file);	# No problem if it doesn't exist yet [startup e.g.]
Index: loncom/lond
diff -u loncom/lond:1.374 loncom/lond:1.375
--- loncom/lond:1.374	Thu May 31 01:17:48 2007
+++ loncom/lond	Mon Jun 18 18:49:52 2007
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.374 2007/05/31 05:17:48 albertel Exp $
+# $Id: lond,v 1.375 2007/06/18 22:49:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.374 $'; #' stupid emacs
+my $VERSION='$Revision: 1.375 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -5486,7 +5486,7 @@
 # ---------------- New known client connecting, could mean machine online again
 	    if (&Apache::lonnet::get_host_ip($currenthostid) ne $clientip 
 		&& $clientip ne '127.0.0.1') {
-		&Apache::lonnet::reconlonc();
+		&Apache::lonnet::reconlonc($clientname);
 	    }
 	    &logthis("<font color='green'>Established connection: $clientname</font>");
 	    &status('Will listen to '.$clientname);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.890 loncom/lonnet/perl/lonnet.pm:1.891
--- loncom/lonnet/perl/lonnet.pm:1.890	Tue Jun 12 23:00:59 2007
+++ loncom/lonnet/perl/lonnet.pm	Mon Jun 18 18:49:57 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.890 2007/06/13 03:00:59 albertel Exp $
+# $Id: lonnet.pm,v 1.891 2007/06/18 22:49:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -214,6 +214,24 @@
 # ----------------------------------------------------------- Send USR1 to lonc
 
 sub reconlonc {
+    my ($lonid) = @_;
+    my $hostname = &hostname($lonid);
+    if ($lonid) {
+	my $peerfile="$perlvar{'lonSockDir'}/$hostname";
+	if ($hostname && -e $peerfile) {
+	    &logthis("Trying to reconnect lonc for $lonid ($hostname)");
+	    my $client=IO::Socket::UNIX->new(Peer    => $peerfile,
+					     Type    => SOCK_STREAM,
+					     Timeout => 10);
+	    if ($client) {
+		print $client ("reset_retries\n");
+		my $answer=<$client>;
+		#reset just this one.
+	    }
+	}
+	return;
+    }
+
     &logthis("Trying to reconnect lonc");
     my $loncfile="$perlvar{'lonDaemons'}/logs/lonc.pid";
     if (open(my $fh,"<$loncfile")) {