[interchange-cvs] interchange - heins modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sun Mar 7 01:59:50 EST 2004


User:      heins
Date:      2004-03-07 06:59:50 GMT
Modified:  lib/Vend Server.pm Config.pm
Log:
* Occasionally in PreFork mode you will find a server that gets "starved",
  in other words never seems to win the battle and receive a page request.
  It just sits there forever, not killable or anything.

  Add ChildLife directive which times out a page server after a period
  of time.

  	ChildLife   30 minutes

  This is the usual Interchange time_to_seconds value.

  If ChildLife is not set, the default, the server will act just
  like it does now, stuck in that internal loop forever until
  kill -9 happens.

  All it does is set the start_time of the server, and then when
  HouseKeeping seconds goes by it checks the current time and lasts
  the server (just like MaxRequestsPerChild, basically) if it
  has expired.

  Should clear up the problem people have with a growing number of
  servers over time.

* Also removed setting of $C->{Source}->{$var} for time_to_seconds
  types, as it triggered a bug within Perl and caused my system
  to barf.

Revision  Changes    Path
2.50      +19 -8     interchange/lib/Vend/Server.pm


rev 2.50, prev_rev 2.49
Index: Server.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Server.pm,v
retrieving revision 2.49
retrieving revision 2.50
diff -u -r2.49 -r2.50
--- Server.pm	6 Mar 2004 22:11:53 -0000	2.49
+++ Server.pm	7 Mar 2004 06:59:50 -0000	2.50
@@ -1,6 +1,6 @@
 # Vend::Server - Listen for Interchange CGI requests as a background server
 #
-# $Id: Server.pm,v 2.49 2004/03/06 22:11:53 mheins Exp $
+# $Id: Server.pm,v 2.50 2004/03/07 06:59:50 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -26,7 +26,7 @@
 package Vend::Server;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.49 $, 10);
+$VERSION = substr(q$Revision: 2.50 $, 10);
 
 use POSIX qw(setsid strftime);
 use Vend::Util;
@@ -1610,10 +1610,13 @@
 	my $rout;
 	my $pid;
 	my $spawn;
+	my $start_time = $Global::ChildLife ? time() : 0;
+	my $end_of_life;
 	my $handled = 0;
 	
 	$Global::Foreground ||= $no_fork;
 
+#::logDebug("Start time is $start_time");
     for (;;) {
 
 	  my $n;
@@ -1640,7 +1643,12 @@
         }
 		elsif($n == 0) {
 			undef $spawn;
-			#indiv_housekeeping();
+			if($start_time) {
+				my $current_time = time();
+				next unless $current_time - $start_time > $Global::ChildLife;
+				$end_of_life = 1;
+				last;
+			}
 			next;
 		}
         else {
@@ -1753,12 +1761,15 @@
 
 		}
 
-		return 1
-			if $no_fork
-			and $Global::MaxRequestsPerChild
-			and $handled >= $Global::MaxRequestsPerChild;
-
 		return if $Signal_Terminate;
+
+		next unless $no_fork;
+		
+		return 1   if $end_of_life;
+
+		return 1   if  $Global::MaxRequestsPerChild
+				   and $handled >= $Global::MaxRequestsPerChild;
+
 
     }
 }



2.135     +6 -3      interchange/lib/Vend/Config.pm


rev 2.135, prev_rev 2.134
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.134
retrieving revision 2.135
diff -u -r2.134 -r2.135
--- Config.pm	7 Mar 2004 03:14:41 -0000	2.134
+++ Config.pm	7 Mar 2004 06:59:50 -0000	2.135
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.134 2004/03/07 03:14:41 mheins Exp $
+# $Id: Config.pm,v 2.135 2004/03/07 06:59:50 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -48,7 +48,7 @@
 use Vend::File;
 use Vend::Data;
 
-$VERSION = substr(q$Revision: 2.134 $, 10);
+$VERSION = substr(q$Revision: 2.135 $, 10);
 
 my %CDname;
 my %CPname;
@@ -299,6 +299,7 @@
 	['SOAP_Socket',       'array',            ''],
 	['SOAP_Perms',        'integer',          0600],
 	['MaxRequestsPerChild','integer',           50],
+	['ChildLife',         'time',             0],
 	['StartServers',      'integer',          0],
 	['PreFork',		      'yesno',            0],
 	['SOAP_MaxRequests', 'integer',           50],
@@ -2916,7 +2917,9 @@
 	my($var, $value) = @_;
 	my($n);
 
-	$C->{Source}->{$var} = [$value];
+	return $value unless $value;
+
+#	$C->{Source}->{$var} = [$value];
 
 	$n = time_to_seconds($value);
 	config_error("Bad time format ('$value') in the $var directive\n")








More information about the interchange-cvs mailing list