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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 05 Oct 2004 11:24:34 -0000


foxr		Tue Oct  5 07:24:34 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  If necessary, wait for the unix socket lock file to disappear before
  connecting to lonc.  Needed to support process trimming in loncnew and
  harmless in pre process trimming implementations of lonc/loncnew since
  those implementations won't ever create the lock file in the first place.
  
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.548 loncom/lonnet/perl/lonnet.pm:1.549
--- loncom/lonnet/perl/lonnet.pm:1.548	Mon Sep 27 15:00:16 2004
+++ loncom/lonnet/perl/lonnet.pm	Tue Oct  5 07:24:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.548 2004/09/27 19:00:16 albertel Exp $
+# $Id: lonnet.pm,v 1.549 2004/10/05 11:24:34 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -116,6 +116,18 @@
 sub subreply {
     my ($cmd,$server)=@_;
     my $peerfile="$perlvar{'lonSockDir'}/$server";
+    #
+    #  With loncnew process trimming, there's a timing hole between lonc server
+    #  process exit and the master server picking up the listen on the AF_UNIX
+    #  socket.  In that time interval, a lock file will exist:
+
+    my $lockfile=$peerfile.".lock";
+    while (-e $lockfile) {	# Need to wait for the lockfile to disappear.
+	sleep(1);
+    }
+    # At this point, either a loncnew parent is listening or an old lonc
+    # or loncnew child is listening so we can connect.
+    #
     my $client=IO::Socket::UNIX->new(Peer    =>"$peerfile",
                                      Type    => SOCK_STREAM,
                                      Timeout => 10)