version 1.384, 2007/10/06 04:32:23
|
version 1.385, 2007/10/08 17:40:56
|
Line 33 use strict;
|
Line 33 use strict;
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA; |
use LONCAPA; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
use Apache::lonnet; |
|
|
|
use IO::Socket; |
use IO::Socket; |
use IO::File; |
use IO::File; |
Line 75 my $keymode;
|
Line 74 my $keymode;
|
|
|
my $cipher; # Cipher key negotiated with client |
my $cipher; # Cipher key negotiated with client |
my $tmpsnum = 0; # Id of tmpputs. |
my $tmpsnum = 0; # Id of tmpputs. |
|
my $max_children = 1; # warn when exceeding this |
|
my $max_children_enforcing = 0; |
|
|
# |
# |
# Connection type is: |
# Connection type is: |
Line 5180 $server = IO::Socket::INET->new(LocalPor
|
Line 5181 $server = IO::Socket::INET->new(LocalPor
|
|
|
my %children = (); # keys are current child process IDs |
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 |
sub REAPER { # takes care of dead children |
$SIG{CHLD} = \&REAPER; |
$SIG{CHLD} = \&REAPER; |
&status("Handling child death"); |
&status("Handling child death"); |
Line 5489 $SIG{INT} = $SIG{TERM} = \&HUNTSMAN;
|
Line 5496 $SIG{INT} = $SIG{TERM} = \&HUNTSMAN;
|
$SIG{HUP} = \&HUPSMAN; |
$SIG{HUP} = \&HUPSMAN; |
$SIG{USR1} = \&checkchildren; |
$SIG{USR1} = \&checkchildren; |
$SIG{USR2} = \&UpdateHosts; |
$SIG{USR2} = \&UpdateHosts; |
|
$SIG{SEGV} = \&flip_max_children_enforcing; |
|
|
# Read the host hashes: |
# Read the host hashes: |
&Apache::lonnet::load_hosts_tab(); |
&Apache::lonnet::load_hosts_tab(); |
Line 5504 while (1) {
|
Line 5512 while (1) {
|
&status('Starting accept'); |
&status('Starting accept'); |
$client = $server->accept() or next; |
$client = $server->accept() or next; |
&status('Accepted '.$client.' off to spawn'); |
&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'); |
&status('Finished spawning'); |
} |
} |
|
|
Line 5707 sub make_new_child {
|
Line 5725 sub make_new_child {
|
# ------------------------------------------------------------ Process requests |
# ------------------------------------------------------------ Process requests |
my $keep_going = 1; |
my $keep_going = 1; |
my $user_input; |
my $user_input; |
|
my $max_size = (split("\n",`ps -o vsz $$`))[-1]; |
while(($user_input = get_request) && $keep_going) { |
while(($user_input = get_request) && $keep_going) { |
alarm(120); |
alarm(120); |
Debug("Main: Got $user_input\n"); |
Debug("Main: Got $user_input\n"); |
$keep_going = &process_request($user_input); |
$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); |
alarm(0); |
&status('Listening to '.$clientname." ($keymode)"); |
&status('Listening to '.$clientname." ($keymode)"); |
} |
} |
Line 6391 sub sethost {
|
Line 6417 sub sethost {
|
eq &Apache::lonnet::get_host_ip($hostid)) { |
eq &Apache::lonnet::get_host_ip($hostid)) { |
$currenthostid =$hostid; |
$currenthostid =$hostid; |
$currentdomainid=&Apache::lonnet::host_domain($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 { |
} else { |
&logthis("Requested host id $hostid not an alias of ". |
&logthis("Requested host id $hostid not an alias of ". |
$perlvar{'lonHostID'}." refusing connection"); |
$perlvar{'lonHostID'}." refusing connection"); |