fat                                      Sat, 18 Jun 2011 16:27:48 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=312261

Log:
Added master rlimit_files and rlimit_core in the global configuration settings

Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.h
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_unix.c
    U   php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in
    U   php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.h
    U   php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_unix.c
    U   php/php-src/branches/PHP_5_4/sapi/fpm/php-fpm.conf.in
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_conf.h
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_unix.c
    U   php/php-src/trunk/sapi/fpm/php-fpm.conf.in

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_3/NEWS	2011-06-18 16:27:48 UTC (rev 312261)
@@ -175,6 +175,8 @@
   . 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

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c	2011-06-18 16:27:48 UTC (rev 312261)
@@ -63,13 +63,15 @@
 #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_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 @@
 			return "must be greater than zero or 'unlimited'";
 		}

-		c->rlimit_core = int_value;
+		*ptr = int_value;
 	}

 	return NULL;
@@ -1117,6 +1119,8 @@
 	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) {

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.h
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.h	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.h	2011-06-18 16:27:48 UTC (rev 312261)
@@ -29,6 +29,8 @@
 	int daemonize;
 	char *pid_file;
 	char *error_log;
+	int rlimit_files;
+	int rlimit_core;
 };

 extern struct fpm_global_config_s fpm_global_config;

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_unix.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_unix.c	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_unix.c	2011-06-18 16:27:48 UTC (rev 312261)
@@ -153,7 +153,7 @@
 		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 @@
 		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 @@
 {
 	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()) {

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in	2011-06-18 16:27:48 UTC (rev 312261)
@@ -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 ;

Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.c	2011-06-18 16:27:48 UTC (rev 312261)
@@ -63,13 +63,15 @@
 #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_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 @@
 			return "must be greater than zero or 'unlimited'";
 		}

-		c->rlimit_core = int_value;
+		*ptr = int_value;
 	}

 	return NULL;
@@ -1117,6 +1119,8 @@
 	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) {

Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.h
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.h	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_conf.h	2011-06-18 16:27:48 UTC (rev 312261)
@@ -29,6 +29,8 @@
 	int daemonize;
 	char *pid_file;
 	char *error_log;
+	int rlimit_files;
+	int rlimit_core;
 };

 extern struct fpm_global_config_s fpm_global_config;

Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_unix.c
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_unix.c	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_unix.c	2011-06-18 16:27:48 UTC (rev 312261)
@@ -153,7 +153,7 @@
 		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 @@
 		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 @@
 {
 	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()) {

Modified: php/php-src/branches/PHP_5_4/sapi/fpm/php-fpm.conf.in
===================================================================
--- php/php-src/branches/PHP_5_4/sapi/fpm/php-fpm.conf.in	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/php-fpm.conf.in	2011-06-18 16:27:48 UTC (rev 312261)
@@ -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 ;

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c	2011-06-18 16:27:48 UTC (rev 312261)
@@ -63,13 +63,15 @@
 #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_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 @@
 			return "must be greater than zero or 'unlimited'";
 		}

-		c->rlimit_core = int_value;
+		*ptr = int_value;
 	}

 	return NULL;
@@ -1117,6 +1119,8 @@
 	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) {

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_conf.h
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_conf.h	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_conf.h	2011-06-18 16:27:48 UTC (rev 312261)
@@ -29,6 +29,8 @@
 	int daemonize;
 	char *pid_file;
 	char *error_log;
+	int rlimit_files;
+	int rlimit_core;
 };

 extern struct fpm_global_config_s fpm_global_config;

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_unix.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_unix.c	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_unix.c	2011-06-18 16:27:48 UTC (rev 312261)
@@ -153,7 +153,7 @@
 		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 @@
 		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 @@
 {
 	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()) {

Modified: php/php-src/trunk/sapi/fpm/php-fpm.conf.in
===================================================================
--- php/php-src/trunk/sapi/fpm/php-fpm.conf.in	2011-06-18 16:15:15 UTC (rev 312260)
+++ php/php-src/trunk/sapi/fpm/php-fpm.conf.in	2011-06-18 16:27:48 UTC (rev 312261)
@@ -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 ;
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to