summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Loyet <fat@php.net>2011-06-18 16:27:48 +0000
committerJérôme Loyet <fat@php.net>2011-06-18 16:27:48 +0000
commit23a5f873fb7e5e313272f16250d55e2d6d391277 (patch)
treeab0cb5caa17806ff02ba1b5e6ab9e64f2250e267
parent6e1f77ef6b2108138a9e541d1bfe66a29b80e426 (diff)
downloadphp-git-23a5f873fb7e5e313272f16250d55e2d6d391277.tar.gz
Added master rlimit_files and rlimit_core in the global configuration settings
-rw-r--r--NEWS2
-rw-r--r--sapi/fpm/fpm/fpm_conf.c22
-rw-r--r--sapi/fpm/fpm/fpm_conf.h2
-rw-r--r--sapi/fpm/fpm/fpm_unix.c26
-rw-r--r--sapi/fpm/php-fpm.conf.in9
5 files changed, 50 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index 78f7bd7bd0..e43ad83b8c 100644
--- a/NEWS
+++ b/NEWS
@@ -175,6 +175,8 @@ PHP NEWS
. Added xml format to the status page. (fat)
. Remove timestamp in logs written by children processes. (fat)
. Fixed exit at FPM startup on fpm_resources_prepare() errors. (fat)
+ . Added master rlimit_files and rlimit_core in the global configuration
+ settings. (fat)
- Reflection extension:
. Fixed bug #54347 (reflection_extension does not lowercase module function
diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
index 5d6fe770cd..a8e2d60e26 100644
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -63,13 +63,15 @@ static char *ini_include = NULL;
#define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
static struct ini_value_parser_s ini_fpm_global_options[] = {
- { "emergency_restart_threshold", &fpm_conf_set_integer, GO(emergency_restart_threshold) },
- { "emergency_restart_interval", &fpm_conf_set_time, GO(emergency_restart_interval) },
- { "process_control_timeout", &fpm_conf_set_time, GO(process_control_timeout) },
- { "daemonize", &fpm_conf_set_boolean, GO(daemonize) },
- { "pid", &fpm_conf_set_string, GO(pid_file) },
- { "error_log", &fpm_conf_set_string, GO(error_log) },
+ { "emergency_restart_threshold", &fpm_conf_set_integer, GO(emergency_restart_threshold) },
+ { "emergency_restart_interval", &fpm_conf_set_time, GO(emergency_restart_interval) },
+ { "process_control_timeout", &fpm_conf_set_time, GO(process_control_timeout) },
+ { "daemonize", &fpm_conf_set_boolean, GO(daemonize) },
+ { "pid", &fpm_conf_set_string, GO(pid_file) },
+ { "error_log", &fpm_conf_set_string, GO(error_log) },
{ "log_level", &fpm_conf_set_log_level, 0 },
+ { "rlimit_files", &fpm_conf_set_integer, GO(rlimit_files) },
+ { "rlimit_core", &fpm_conf_set_rlimit_core,GO(rlimit_core) },
{ 0, 0, 0 }
};
@@ -255,10 +257,10 @@ static char *fpm_conf_set_log_level(zval *value, void **config, intptr_t offset)
static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offset) /* {{{ */
{
char *val = Z_STRVAL_P(value);
- struct fpm_worker_pool_config_s *c = *config;
+ int *ptr = (int *) ((char *) *config + offset);
if (!strcasecmp(val, "unlimited")) {
- c->rlimit_core = -1;
+ *ptr = -1;
} else {
int int_value;
void *subconf = &int_value;
@@ -274,7 +276,7 @@ static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offse
return "must be greater than zero or 'unlimited'";
}
- c->rlimit_core = int_value;
+ *ptr = int_value;
}
return NULL;
@@ -1117,6 +1119,8 @@ static void fpm_conf_dump() /* {{{ */
zlog(ZLOG_NOTICE, "\tprocess_control_timeout = %ds", fpm_global_config.process_control_timeout);
zlog(ZLOG_NOTICE, "\temergency_restart_interval = %ds", fpm_global_config.emergency_restart_interval);
zlog(ZLOG_NOTICE, "\temergency_restart_threshold = %d", fpm_global_config.emergency_restart_threshold);
+ zlog(ZLOG_NOTICE, "\trlimit_files = %d", fpm_global_config.rlimit_files);
+ zlog(ZLOG_NOTICE, "\trlimit_core = %d", fpm_global_config.rlimit_core);
zlog(ZLOG_NOTICE, " ");
for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h
index ac38ee2e9a..64b569006e 100644
--- a/sapi/fpm/fpm/fpm_conf.h
+++ b/sapi/fpm/fpm/fpm_conf.h
@@ -29,6 +29,8 @@ struct fpm_global_config_s {
int daemonize;
char *pid_file;
char *error_log;
+ int rlimit_files;
+ int rlimit_core;
};
extern struct fpm_global_config_s fpm_global_config;
diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c
index d63ea4d5b0..d29d387995 100644
--- a/sapi/fpm/fpm/fpm_unix.c
+++ b/sapi/fpm/fpm/fpm_unix.c
@@ -153,7 +153,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
r.rlim_max = r.rlim_cur = (rlim_t) wp->config->rlimit_files;
if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
- zlog(ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno);
+ zlog(ZLOG_SYSERROR, "[pool %s] unable to set rlimit_files for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno);
}
}
@@ -163,7 +163,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
r.rlim_max = r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->config->rlimit_core;
if (0 > setrlimit(RLIMIT_CORE, &r)) {
- zlog(ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno);
+ zlog(ZLOG_SYSERROR, "[pool %s] unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno);
}
}
@@ -220,6 +220,28 @@ int fpm_unix_init_main() /* {{{ */
{
struct fpm_worker_pool_s *wp;
+ if (fpm_global_config.rlimit_files) {
+ struct rlimit r;
+
+ r.rlim_max = r.rlim_cur = (rlim_t) fpm_global_config.rlimit_files;
+
+ if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
+ zlog(ZLOG_SYSERROR, "unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_files. setrlimit(RLIMIT_NOFILE, %d) failed (%d)", fpm_global_config.rlimit_files, errno);
+ return -1;
+ }
+ }
+
+ if (fpm_global_config.rlimit_core) {
+ struct rlimit r;
+
+ r.rlim_max = r.rlim_cur = fpm_global_config.rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) fpm_global_config.rlimit_core;
+
+ if (0 > setrlimit(RLIMIT_CORE, &r)) {
+ zlog(ZLOG_SYSERROR, "unable to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d) failed (%d)", fpm_global_config.rlimit_core, errno);
+ return -1;
+ }
+ }
+
fpm_pagesize = getpagesize();
if (fpm_global_config.daemonize) {
switch (fork()) {
diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in
index 6821789bd1..e8b39bcdea 100644
--- a/sapi/fpm/php-fpm.conf.in
+++ b/sapi/fpm/php-fpm.conf.in
@@ -57,6 +57,15 @@
; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes
+
+; Set open file descriptor rlimit for the master process.
+; Default Value: system defined value
+;rlimit_files = 1024
+
+; Set max core size rlimit for the master process.
+; Possible Values: 'unlimited' or an integer greater or equal to 0
+; Default Value: system defined value
+;rlimit_core = 0
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;