[LON-CAPA-cvs] cvs: loncom / loncnew

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 17 Jan 2005 22:18:44 -0000


albertel		Mon Jan 17 17:18:44 2005 EDT

  Modified files:              
    /loncom	loncnew 
  Log:
  - getting rid of the sleep 1, byy using locking instead
  
  
Index: loncom/loncnew
diff -u loncom/loncnew:1.66 loncom/loncnew:1.67
--- loncom/loncnew:1.66	Mon Jan 17 15:35:14 2005
+++ loncom/loncnew	Mon Jan 17 17:18:44 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # lonc maintains the connections to remote computers
 #
-# $Id: loncnew,v 1.66 2005/01/17 20:35:14 albertel Exp $
+# $Id: loncnew,v 1.67 2005/01/17 22:18:44 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,6 +61,7 @@
 use LONCAPA::LondTransaction;
 use LONCAPA::Configuration;
 use LONCAPA::HashIterator;
+use Fcntl qw(:flock);
 
 
 # Read the httpd configuration file to get perl variables
@@ -1566,25 +1567,29 @@
 
     Debug(2, "Reporting child status because : ".$watcher->data);
     my $docdir = $perlvar{'lonDocRoot'};
-    my $fh = IO::File->new(">>$docdir/lon-status/loncstatus.txt");
-    print $fh $$."\t".$RemoteHost."\t".$Status."\t".
+    
+    open(LOG,">>$docdir/lon-status/loncstatus.txt");
+    flock(LOG,LOCK_EX);
+    print LOG $$."\t".$RemoteHost."\t".$Status."\t".
 	$RecentLogEntry."\n";
     #
     #  Write out information about each of the connections:
     #
     if ($DebugLevel > 2) {
-	print $fh "Active connection statuses: \n";
+	print LOG "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 LOG "Connection $i State: $state\n";
 	    print STDERR "---------------------- Connection $i \n";
 	    $Socket->Dump(-1);	# Ensure it gets dumped..
 	    $i++;	
 	}
     }
+    flock(LOG,LOCK_UN);
+    close(LOG);
     $ConnectionRetriesLeft = $ConnectionRetries;
 }
 
@@ -2057,7 +2062,6 @@
     foreach my $pid (keys %ChildHash) {
 	Debug(2, "Sending USR1 -> $pid");
 	kill 'USR1' => $pid;	# Tell Child to report status.
-	sleep 1;		# Wait so file doesn't intermix.
     }
 
 }