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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Mon, 08 Oct 2007 17:40:58 -0000


albertel		Mon Oct  8 13:40:58 2007 EDT

  Modified files:              
    /loncom	lond 
  Log:
  - remove duplicate use
  
  
Index: loncom/lond
diff -u loncom/lond:1.384 loncom/lond:1.385
--- loncom/lond:1.384	Sat Oct  6 00:32:23 2007
+++ loncom/lond	Mon Oct  8 13:40:56 2007
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.384 2007/10/06 04:32:23 raeburn Exp $
+# $Id: lond,v 1.385 2007/10/08 17:40:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,7 +33,6 @@
 use lib '/home/httpd/lib/perl/';
 use LONCAPA;
 use LONCAPA::Configuration;
-use Apache::lonnet;
 
 use IO::Socket;
 use IO::File;
@@ -60,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.384 $'; #' stupid emacs
+my $VERSION='$Revision: 1.385 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -75,6 +74,8 @@
 
 my $cipher;			# Cipher key negotiated with client
 my $tmpsnum = 0;		# Id of tmpputs.
+my $max_children = 1;           # warn when exceeding this
+my $max_children_enforcing = 0;
 
 # 
 #   Connection type is:
@@ -5180,6 +5181,12 @@
 
 my %children               = ();       # keys are current child process IDs
 
+sub flip_max_children_enforcing {
+    $max_children_enforcing = !$max_children_enforcing;
+    &logthis("Flipped child maximum enforcement to (".
+	     $max_children_enforcing.")");
+}
+
 sub REAPER {                        # takes care of dead children
     $SIG{CHLD} = \&REAPER;
     &status("Handling child death");
@@ -5489,6 +5496,7 @@
 $SIG{HUP}  = \&HUPSMAN;
 $SIG{USR1} = \&checkchildren;
 $SIG{USR2} = \&UpdateHosts;
+$SIG{SEGV} = \&flip_max_children_enforcing;
 
 #  Read the host hashes:
 &Apache::lonnet::load_hosts_tab();
@@ -5504,7 +5512,17 @@
     &status('Starting accept');
     $client = $server->accept() or next;
     &status('Accepted '.$client.' off to spawn');
-    make_new_child($client);
+    my $child_count = scalar(keys(%children));
+    if ($child_count > $max_children) {
+	&logthis("Warning too many children (".$child_count.")");
+    }
+#    if ($child_count > $max_children && $max_children_enforcing) {
+#	&logthis(" Not creating new child ");
+#	$client->close();
+#    } else {
+	&make_new_child($client);
+#    }
+    &logthis("Concurrent children at ($child_count)");
     &status('Finished spawning');
 }
 
@@ -5707,10 +5725,18 @@
 # ------------------------------------------------------------ Process requests
 	    my $keep_going = 1;
 	    my $user_input;
+	    my $max_size = (split("\n",`ps -o vsz $$`))[-1];
 	    while(($user_input = get_request) && $keep_going) {
 		alarm(120);
 		Debug("Main: Got $user_input\n");
 		$keep_going = &process_request($user_input);
+		if (!$max_children_enforcing) {
+		    my $new_size = (split("\n",`ps -o vsz $$`))[-1];
+		    if ($new_size > $max_size) {
+			&logthis("size increase of ".($new_size-$max_size)." ($new_size) while processing (".length($user_input).")\n".substr($user_input,0,80));
+			$max_size = $new_size;
+		    }
+		}
 		alarm(0);
 		&status('Listening to '.$clientname." ($keymode)");	   
 	    }
@@ -6391,7 +6417,7 @@
 	eq &Apache::lonnet::get_host_ip($hostid)) {
 	$currenthostid  =$hostid;
 	$currentdomainid=&Apache::lonnet::host_domain($hostid);
-	&logthis("Setting hostid to $hostid, and domain to $currentdomainid");
+	#&logthis("Setting hostid to $hostid, and domain to $currentdomainid");
     } else {
 	&logthis("Requested host id $hostid not an alias of ".
 		 $perlvar{'lonHostID'}." refusing connection");