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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 21 Oct 2003 14:24:42 -0000


foxr		Tue Oct 21 10:24:42 2003 EDT

  Modified files:              
    /loncom	loncnew 
  Log:
  Fix little typo that may explain growth of connections
  
  
Index: loncom/loncnew
diff -u loncom/loncnew:1.28 loncom/loncnew:1.29
--- loncom/loncnew:1.28	Tue Oct 14 11:36:21 2003
+++ loncom/loncnew	Tue Oct 21 10:24:42 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # lonc maintains the connections to remote computers
 #
-# $Id: loncnew,v 1.28 2003/10/14 15:36:21 albertel Exp $
+# $Id: loncnew,v 1.29 2003/10/21 14:24:42 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -45,6 +45,9 @@
 
 # Change log:
 #    $Log: loncnew,v $
+#    Revision 1.29  2003/10/21 14:24:42  foxr
+#    Fix little typo that may explain growth of connections
+#
 #    Revision 1.28  2003/10/14 15:36:21  albertel
 #    - making it easier to run loncnew,
 #       /etc/init.d/loncontrol startnew
@@ -181,7 +184,7 @@
 my $ClientConnection = 0;	# Uniquifier for client events.
 
 my $DebugLevel = 0;
-my $NextDebugLevel= 10;		# So Sigint can toggle this.
+my $NextDebugLevel= 2;		# So Sigint can toggle this.
 my $IdleTimeout= 3600;		# Wait an hour before pruning connections.
 
 #
@@ -409,18 +412,18 @@
 	if ($ConnectionRetriesLeft > 0) {
 	    my $Connections = ($Requests <= $MaxConnectionCount) ?
 		$Requests : $MaxConnectionCount;
-	    Debug(1,"Work but no connections, start ".$Connections." of them");
+	    Debug(5,"Work but no connections, start ".$Connections." of them");
 	    my $successCount = 0;
 	    for (my $i =0; $i < $Connections; $i++) {
 		$successCount += MakeLondConnection();
 	    }
 	    if($successCount == 0) { # All connections failed:
-		Debug(1,"Work in queue failed to make any connectiouns\n");
+		Debug(5,"Work in queue failed to make any connectiouns\n");
 		EmptyQueue();	# Fail pending transactions with con_lost.
 	    }
 	} else {
 	    ShowStatus(GetServerHost()." >>> DEAD!!! <<<");
-	    Debug(1,"Work in queue, but gave up on connections..flushing\n");
+	    Debug(5,"Work in queue, but gave up on connections..flushing\n");
 	    EmptyQueue();	# Connections can't be established.
 	}
        
@@ -467,19 +470,19 @@
     my $Socket   = shift;	# Get the socket.
     delete($ActiveTransactions{$Socket}); # Server has no transaction
 
-    &Debug(6, "Server to idle");
+    &Debug(5, "Server to idle");
 
     #  If there's work to do, start the transaction:
 
     my $reqdata = $WorkQueue->dequeue(); # This is a LondTransaction
-    unless($reqdata eq undef)  {
-	Debug(9, "Queue gave request data: ".$reqdata->getRequest());
+    if ($reqdata ne undef)  {
+	Debug(5, "Queue gave request data: ".$reqdata->getRequest());
 	&StartRequest($Socket,  $reqdata);
 
     } else {
 	
     #  There's no work waiting, so push the server to idle list.
-	&Debug(8, "No new work requests, server connection going idle");
+	&Debug(5, "No new work requests, server connection going idle");
 	$IdleConnections->push($Socket);
     }
 }
@@ -525,7 +528,7 @@
 	# request.
 	
 	&Debug(9,"Send result is ".$result." Defined: ".defined($result));
-	if(defined($result)) {
+	if($result ne undef) {
 	    &Debug(9, "send result was defined");
 	    if($result == length($Data)) { # Entire string sent.
 		&Debug(9, "ClientWritable data all written");
@@ -596,7 +599,7 @@
 =cut
 
 sub CompleteTransaction {
-    &Debug(6,"Complete transaction");
+    &Debug(5,"Complete transaction");
     my $Socket = shift;
     my $Transaction = shift;
 
@@ -635,7 +638,6 @@
     &Debug(8," Reply was: ".$data);
     my $Serial         = $ActiveClients{$Client};
     my $desc           = sprintf("Connection to lonc client %d",
-
 				 $Serial);
     Event->io(fd       => $Client,
 	      poll     => "w",
@@ -667,10 +669,10 @@
 sub FailTransaction {
     my $transaction = shift;
     Log("WARNING", "Failing transaction ".$transaction->getRequest());
-    Debug(1, "Failing transaction: ".$transaction->getRequest());
+    Debug(5, "Failing transaction: ".$transaction->getRequest());
     if (!$transaction->isDeferred()) { # If the transaction is deferred we'll get to it.
 	my $client  = $transaction->getClient();
-	Debug(1," Replying con_lost to ".$transaction->getRequest());
+	Debug(5," Replying con_lost to ".$transaction->getRequest());
 	StartClientReply($transaction, "con_lost\n");
     }
     if($ConnectionRetriesLeft <= 0) {
@@ -884,7 +886,7 @@
 	$ConnectionRetriesLeft = $ConnectionRetries; # success resets the count
 	$Watcher->cancel();
 	if(exists($ActiveTransactions{$Socket})) {
-	    Debug(8,"Completing transaction!!");
+	    Debug(5,"Completing transaction!!");
 	    CompleteTransaction($Socket, 
 				$ActiveTransactions{$Socket});
 	} else {
@@ -1246,11 +1248,11 @@
 
     my $LondSocket    = $IdleConnections->pop();
     if(!defined $LondSocket) {	# Need to queue request.
-	Debug(8,"Must queue...");
+	Debug(5,"Must queue...");
 	$WorkQueue->enqueue($requestData);
 	if($ConnectionCount < $MaxConnectionCount) {
 	    if($ConnectionRetriesLeft > 0) {
-		Debug(4,"Starting additional lond connection");
+		Debug(5,"Starting additional lond connection");
 		if(MakeLondConnection() == 0) {
 		    EmptyQueue();	# Fail transactions, can't make connection.
 		}
@@ -1288,7 +1290,7 @@
     my $rv = $socket->recv($thisread, POSIX::BUFSIZ, 0);
     Debug(8, "rcv:  data length = ".length($thisread)
 	  ." read =".$thisread);
-    unless (defined $rv && length($thisread)) {
+    unless (defined $rv  && length($thisread)) {
 	 # Likely eof on socket.
 	Debug(5,"Client Socket closed on lonc for ".$RemoteHost);
 	close($socket);