@@ -1224,7 +1224,7 @@ sub feature_save_web_php_mode
12241224 my $ok ;
12251225 $d -> {' nginx_php_version' } ||= $tmpl -> {' web_phpver' };
12261226 $d -> {' nginx_php_children' } ||= $config {' child_procs' } ||
1227- $tmpl -> {' web_phpchildren' } || 1 ;
1227+ $tmpl -> {' web_phpchildren' } || 0 ;
12281228 ($ok , $port ) = &setup_php_fcgi_server($d );
12291229 $ok || return $port ;
12301230 $d -> {' nginx_php_port' } = $port ;
@@ -1403,6 +1403,7 @@ sub feature_get_fcgid_max_execution_time
14031403{
14041404my ($d ) = @_ ;
14051405my $server = &find_domain_server($d );
1406+ my $maxexectime = $virtual_server::max_php_fcgid_timeout || 9999;
14061407if ($server ) {
14071408 my $ver = &get_nginx_version();
14081409 $ver =~ s / ^(\d +\.\d +)(.*)/ $1 / ;
@@ -1411,12 +1412,12 @@ sub feature_get_fcgid_max_execution_time
14111412 my ($t ) = grep { $_ -> {' words' }-> [0] eq " read_timeout" }
14121413 &find(" fastcgi_param" , $server );
14131414 my $v = $t ? $t -> {' words' }-> [1] : undef ;
1414- return !$v ? undef : $v == 9999 ? undef : $v ;
1415+ return !$v ? undef : $v == $maxexectime ? undef : $v ;
14151416 }
14161417 else {
14171418 # Old format directive
14181419 my $t = &find_value(" fastcgi_read_timeout" , $server );
1419- return $t == 9999 ? undef : $t if ($t );
1420+ return $t == $maxexectime ? undef : $t if ($t );
14201421 }
14211422 return &get_default(" fastcgi_read_timeout" );
14221423 }
@@ -1429,6 +1430,7 @@ sub feature_set_fcgid_max_execution_time
14291430my ($d , $max ) = @_ ;
14301431&lock_all_config_files();
14311432my $server = &find_domain_server($d );
1433+ my $maxexectime = $virtual_server::max_php_fcgid_timeout || 9999;
14321434if ($server ) {
14331435 my $ver = &get_nginx_version();
14341436 $ver =~ s / ^(\d +\.\d +)(.*)/ $1 / ;
@@ -1437,13 +1439,13 @@ sub feature_set_fcgid_max_execution_time
14371439 my @p = &find(" fastcgi_param" , $server );
14381440 @p = grep { $_ -> {' words' }-> [0] ne ' read_timeout' } @p ;
14391441 push (@p , { ' name' => ' fastcgi_param' ,
1440- ' words' => [ " read_timeout" , ($max || 9999 ) ] });
1442+ ' words' => [ " read_timeout" , ($max || $maxexectime ) ] });
14411443 &save_directive($server , " fastcgi_param" , \@p );
14421444 }
14431445 else {
14441446 # Old format directive
14451447 &save_directive($server , " fastcgi_read_timeout" ,
1446- [ $max || 9999 ]);
1448+ [ $max || $maxexectime ]);
14471449 }
14481450 }
14491451&flush_config_file_lines();
@@ -1483,24 +1485,28 @@ sub feature_get_web_php_children
14831485{
14841486my ($d ) = @_ ;
14851487my $mode = &feature_get_web_php_mode($d );
1488+ my $childrenmax =
1489+ defined (&virtual_server::get_php_max_childred_allowed) ?
1490+ &virtual_server::get_php_max_childred_allowed() :
1491+ $virtual_server::max_php_fcgid_children ;
14861492if ($mode eq " fcgid" ) {
14871493 # Stored in the domain's config
1488- return $d -> {' nginx_php_children' } || 1 ;
1494+ return $d -> {' nginx_php_children' } || 0 ;
14891495 }
14901496elsif ($mode eq " fpm" ) {
14911497 # Read from FPM config file
1492- my $conf = &virtual_server::get_php_fpm_config();
1493- return -1 if (!$conf );
1494- my $file = $conf -> {' dir' }." /" .$d -> {' id' }." .conf" ;
1495- my $lref = &read_file_lines($file , 1);
1496- my $childs = 0;
1497- foreach my $l (@$lref ) {
1498- if ($l =~ / pm.max_children\s *=\s *(\d +)/ ) {
1499- $childs = $1 ;
1500- }
1501- }
1502- &unflush_file_lines($file );
1503- return $childs == 9999 ? 0 : $childs ;
1498+ my $conf = &virtual_server::get_php_fpm_config();
1499+ return -1 if (!$conf );
1500+ my $file = $conf -> {' dir' }." /" .$d -> {' id' }." .conf" ;
1501+ my $lref = &read_file_lines($file , 1);
1502+ my $childs = 0;
1503+ foreach my $l (@$lref ) {
1504+ if ($l =~ / pm.max_children\s *=\s *(\d +)/ ) {
1505+ $childs = $1 ;
1506+ }
1507+ }
1508+ &unflush_file_lines($file );
1509+ return $childs == $childrenmax ? 0 : $childs ;
15041510 }
15051511else {
15061512 return undef ;
@@ -1512,7 +1518,11 @@ sub feature_get_web_php_children
15121518sub feature_save_web_php_children
15131519{
15141520my ($d , $children ) = @_ ;
1515- $d -> {' nginx_php_children' } ||= 1;
1521+ my $childrenmax =
1522+ defined (&virtual_server::get_php_max_childred_allowed) ?
1523+ &virtual_server::get_php_max_childred_allowed() :
1524+ $virtual_server::max_php_fcgid_children ;
1525+ $d -> {' nginx_php_children' } ||= 0;
15161526if ($children != $d -> {' nginx_php_children' }) {
15171527 $d -> {' nginx_php_children' } = $children ;
15181528 my $mode = &feature_get_web_php_mode($d );
@@ -1529,7 +1539,7 @@ sub feature_save_web_php_children
15291539 return 0 if (!-r $file );
15301540 &lock_file($file );
15311541 my $lref = &read_file_lines($file );
1532- $children = 9999 if ($children == 0); # Unlimited
1542+ $children = $childrenmax if ($children == 0); # Recommended default
15331543 foreach my $l (@$lref ) {
15341544 if ($l =~ / pm.max_children\s *=\s *(\d +)/ ) {
15351545 $l = " pm.max_children = $children " ;
0 commit comments