Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: sapi/fpm/php-fpm.conf.in
- ===================================================================
- --- sapi/fpm/php-fpm.conf.in (revision 312829)
- +++ sapi/fpm/php-fpm.conf.in (working copy)
- @@ -14,6 +14,7 @@
- ; - @prefix@ otherwise
- ;include=etc/fpm.d/*.conf
- +
- ;;;;;;;;;;;;;;;;;;
- ; Global Options ;
- ;;;;;;;;;;;;;;;;;;
- @@ -67,15 +68,35 @@
- ; Default Value: system defined value
- ;rlimit_core = 0
- -;;;;;;;;;;;;;;;;;;;;
- -; Pool Definitions ;
- -;;;;;;;;;;;;;;;;;;;;
- +;;;;;;;;;;;;;;;;;;
- +; Default values ;
- +;;;;;;;;;;;;;;;;;;
- +
- ; Multiple pools of child processes may be started with different listening
- ; ports and different management options. The name of the pool will be
- ; used in logs and stats. There is no limitation on the number of pools which
- -; FPM can handle. Your system will tell you anyway :)
- +; FPM can handle, your system will limit that for you :)
- +; You can put in the defaults section all the same values you would put in a
- +; pool (see below for more details). The defaults are used in case you don't
- +; specify another value in the pool.
- +; If a parameter is not specified either in the defaults section nor in the
- +; pool specific section, a buil-in global default will be used, as explained
- +; in a option by option basis.
- +
- +[defaults]
- +
- +; reasonable values for a small sized server (see below for details)
- +pm.start_servers = 10
- +pm.min_spare_servers = 5
- +pm.max_spare_servers = 35
- +
- +
- +;;;;;;;;;;;;;;;;;;;;
- +; Pool Definitions ;
- +;;;;;;;;;;;;;;;;;;;;
- +
- ; Start a new pool named 'www'.
- ; the variable $pool can we used in any directive and will be replaced by the
- ; pool name ('www' here)
- @@ -94,6 +115,12 @@
- ; Default Value: none
- ;prefix = /path/to/pools/$pool
- +; Unix user/group of processes
- +; Note: The user is mandatory. If the group is not set, the default user's group
- +; will be used.
- +user = @php_fpm_user@
- +group = @php_fpm_group@
- +
- ; The address on which to accept FastCGI requests.
- ; Valid syntaxes are:
- ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
- @@ -125,12 +152,6 @@
- ;listen.group = @php_fpm_group@
- ;listen.mode = 0666
- -; Unix user/group of processes
- -; Note: The user is mandatory. If the group is not set, the default user's group
- -; will be used.
- -user = @php_fpm_user@
- -group = @php_fpm_group@
- -
- ; Choose how the process manager will control the number of child processes.
- ; Possible Values:
- ; static - a fixed number (pm.max_children) of child processes;
- @@ -278,7 +299,7 @@
- ; anything, but it may not be a good idea to use the .php extension or it
- ; may conflict with a real PHP file.
- ; Default Value: not set
- -;pm.status_path = /status
- +;diagnostics.status_path = /status
- ; The ping URI to call the monitoring page of FPM. If this value is not set, no
- ; URI will be recognized as a ping page. This could be used to test from outside
- @@ -290,12 +311,12 @@
- ; anything, but it may not be a good idea to use the .php extension or it
- ; may conflict with a real PHP file.
- ; Default Value: not set
- -;ping.path = /ping
- +;diagnostics.ping_path = /ping
- ; This directive may be used to customize the response of a ping request. The
- ; response is formatted as text/plain with a 200 response code.
- ; Default Value: pong
- -;ping.response = pong
- +;diagnostics.ping_response = pong
- ; The access log file
- ; Default: not set
- @@ -322,7 +343,7 @@
- ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
- ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
- ; %f: script filename
- -: %l: content-length of the request (for POST request only)
- +; %l: content-length of the request (for POST request only)
- ; %m: request method
- ; %M: peak of memory allocated by PHP
- ; it can accept the following format:
- @@ -355,6 +376,11 @@
- ;
- ; Default: "%R - %u %t \"%m %r\" %s"
- ;access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%
- +
- +; The log file for slow requests
- +; Default Value: not set
- +; Note: slowlog is mandatory if request_slowlog_timeout is set
- +;slowlog = log/$pool.log.slow
- ; The timeout for serving a single request after which the worker process will
- ; be killed. This option should be used when the 'max_execution_time' ini option
- @@ -369,11 +395,6 @@
- ; Default Value: 0
- ;request_slowlog_timeout = 0
- -; The log file for slow requests
- -; Default Value: not set
- -; Note: slowlog is mandatory if request_slowlog_timeout is set
- -;slowlog = log/$pool.log.slow
- -
- ; Set open file descriptor rlimit.
- ; Default Value: system defined value
- ;rlimit_files = 1024
- Index: sapi/fpm/fpm/fpm.c
- ===================================================================
- --- sapi/fpm/fpm/fpm.c (revision 312829)
- +++ sapi/fpm/fpm/fpm.c (working copy)
- @@ -49,27 +49,29 @@
- fpm_globals.prefix = prefix;
- fpm_globals.pid = pid;
- - if (0 > fpm_php_init_main() ||
- - 0 > fpm_stdio_init_main() ||
- - 0 > fpm_conf_init_main(test_conf) ||
- - 0 > fpm_unix_init_main() ||
- - 0 > fpm_scoreboard_init_main() ||
- - 0 > fpm_pctl_init_main() ||
- - 0 > fpm_env_init_main() ||
- - 0 > fpm_signals_init_main() ||
- - 0 > fpm_children_init_main() ||
- - 0 > fpm_sockets_init_main() ||
- - 0 > fpm_worker_pool_init_main() ||
- - 0 > fpm_event_init_main()) {
- -
- + if (0 > fpm_php_init_main() ||
- + 0 > fpm_stdio_init_main() ||
- + 0 > fpm_conf_init_main(test_conf) ||
- + 0 > fpm_unix_init_main() ||
- + 0 > fpm_scoreboard_init_main() ||
- + 0 > fpm_pctl_init_main() ||
- + 0 > fpm_env_init_main() ||
- + 0 > fpm_signals_init_main() ||
- + 0 > fpm_children_init_main() ||
- + 0 > fpm_sockets_init_main() ||
- + 0 > fpm_worker_pool_init_main() ||
- + 0 > fpm_event_init_main()) {
- +
- if (fpm_globals.test_successful) {
- exit(0);
- } else {
- + zlog(ZLOG_ERROR, "FPM initialization failed");
- return -1;
- }
- }
- if (0 > fpm_conf_write_pid()) {
- + zlog(ZLOG_ERROR, "FPM initialization failed");
- return -1;
- }
- @@ -114,4 +116,3 @@
- return fpm_globals.listening_socket;
- }
- /* }}} */
- -
- Index: sapi/fpm/fpm/fpm_stdio.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_stdio.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_stdio.c (working copy)
- @@ -25,16 +25,17 @@
- {
- int fd = open("/dev/null", O_RDWR);
- - if (0 > fd) {
- + if (fd < 0) {
- zlog(ZLOG_SYSERROR, "open(\"/dev/null\") failed");
- return -1;
- }
- - if (0 > dup2(fd, STDIN_FILENO) || 0 > dup2(fd, STDOUT_FILENO)) {
- + if (dup2(fd, STDIN_FILENO) < 0 || dup2(fd, STDOUT_FILENO) < 0) {
- zlog(ZLOG_SYSERROR, "dup2() failed");
- return -1;
- }
- close(fd);
- +
- return 0;
- }
- /* }}} */
- @@ -250,7 +251,7 @@
- int fd;
- fd = open(fpm_global_config.error_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
- - if (0 > fd) {
- + if (fd < 0) {
- zlog(ZLOG_SYSERROR, "open(\"%s\") failed", fpm_global_config.error_log);
- return -1;
- }
- Index: sapi/fpm/fpm/fpm_unix.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_unix.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_unix.c (working copy)
- @@ -74,14 +74,13 @@
- static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
- {
- int is_root = !geteuid();
- + struct passwd *pwd;
- if (is_root) {
- if (wp->config->user && *wp->config->user) {
- if (strlen(wp->config->user) == strspn(wp->config->user, "0123456789")) {
- wp->set_uid = strtoul(wp->config->user, 0, 10);
- } else {
- - struct passwd *pwd;
- -
- pwd = getpwnam(wp->config->user);
- if (!pwd) {
- zlog(ZLOG_ERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, wp->config->user);
- @@ -119,25 +118,23 @@
- #endif
- } else { /* not root */
- if (wp->config->user && *wp->config->user) {
- - zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored", wp->config->name);
- + zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored (not running as root)", wp->config->name);
- }
- if (wp->config->group && *wp->config->group) {
- - zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored", wp->config->name);
- + zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored (not running as root)", wp->config->name);
- }
- if (wp->config->chroot && *wp->config->chroot) {
- - zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored", wp->config->name);
- + zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored (not running as root)", wp->config->name);
- }
- - { /* set up HOME and USER anyway */
- - struct passwd *pwd;
- -
- - pwd = getpwuid(getuid());
- - if (pwd) {
- - wp->user = strdup(pwd->pw_name);
- - wp->home = strdup(pwd->pw_dir);
- - }
- + /* set up HOME and USER anyway */
- + pwd = getpwuid(getuid());
- + if (pwd) {
- + wp->user = strdup(pwd->pw_name);
- + wp->home = strdup(pwd->pw_dir);
- }
- }
- +
- return 0;
- }
- /* }}} */
- Index: sapi/fpm/fpm/fpm_status.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_status.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_status.c (working copy)
- @@ -22,22 +22,15 @@
- int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
- {
- - if (!wp || !wp->config) {
- - zlog(ZLOG_ERROR, "unable to init fpm_status because conf structure is NULL");
- - return -1;
- - }
- + assert(wp);
- - if (wp->config->pm_status_path) {
- - fpm_status_uri = strdup(wp->config->pm_status_path);
- + if (wp->config->diag_status_path) {
- + fpm_status_uri = strdup(wp->config->diag_status_path);
- }
- - if (wp->config->ping_path) {
- - if (!wp->config->ping_response) {
- - zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
- - return -1;
- - }
- - fpm_status_ping_uri = strdup(wp->config->ping_path);
- - fpm_status_ping_response = strdup(wp->config->ping_response);
- + if (wp->config->diag_ping_path && wp->config->diag_ping_response) {
- + fpm_status_ping_uri = strdup(wp->config->diag_ping_path);
- + fpm_status_ping_response = strdup(wp->config->diag_ping_response);
- }
- return 0;
- Index: sapi/fpm/fpm/fpm_conf.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_conf.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_conf.c (working copy)
- @@ -44,6 +44,10 @@
- #include "fpm_log.h"
- #include "zlog.h"
- +#define STR2STR(a) (a ? a : "undefined")
- +#define BOOL2STR(a) (a ? "yes" : "no")
- +#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
- +
- static int fpm_conf_load_ini_file(char *filename TSRMLS_DC);
- static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset);
- static char *fpm_conf_set_time(zval *value, void **config, intptr_t offset);
- @@ -53,8 +57,22 @@
- static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offset);
- static char *fpm_conf_set_pm(zval *value, void **config, intptr_t offset);
- -struct fpm_global_config_s fpm_global_config = { .daemonize = 1 };
- -static struct fpm_worker_pool_s *current_wp = NULL;
- +struct fpm_global_config_s fpm_global_config = {
- + .daemonize = 1
- +};
- +
- +static struct fpm_worker_pool_config_s fpm_pool_default_config = {
- + .user = "nobody",
- + .group = "nobody",
- + .pm_max_children = 50,
- + .pm_max_requests = 0,
- + .pm_max_spare_servers = 15,
- + .pm_start_servers = 5,
- + .diag_ping_response = "pong",
- + .listen_backlog = FPM_BACKLOG_DEFAULT
- +};
- +
- +static struct fpm_worker_pool_config_s *ini_current_config = NULL;
- static int ini_recursion = 0;
- static char *ini_filename = NULL;
- static int ini_lineno = 0;
- @@ -64,47 +82,61 @@
- #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) },
- - { "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) },
- + { "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 }
- };
- static struct ini_value_parser_s ini_fpm_pool_options[] = {
- - { "prefix", &fpm_conf_set_string, WPO(prefix) },
- - { "user", &fpm_conf_set_string, WPO(user) },
- - { "group", &fpm_conf_set_string, WPO(group) },
- - { "chroot", &fpm_conf_set_string, WPO(chroot) },
- - { "chdir", &fpm_conf_set_string, WPO(chdir) },
- - { "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
- - { "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
- - { "slowlog", &fpm_conf_set_string, WPO(slowlog) },
- - { "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
- - { "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
- - { "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) },
- - { "listen", &fpm_conf_set_string, WPO(listen_address) },
- - { "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
- - { "listen.group", &fpm_conf_set_string, WPO(listen_group) },
- - { "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
- - { "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
- - { "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
- - { "pm", &fpm_conf_set_pm, WPO(pm) },
- - { "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
- - { "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
- - { "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
- - { "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
- - { "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
- - { "pm.status_path", &fpm_conf_set_string, WPO(pm_status_path) },
- - { "ping.path", &fpm_conf_set_string, WPO(ping_path) },
- - { "ping.response", &fpm_conf_set_string, WPO(ping_response) },
- - { "access.log", &fpm_conf_set_string, WPO(access_log) },
- - { "access.format", &fpm_conf_set_string, WPO(access_format) },
- + { "prefix", &fpm_conf_set_string, WPO(prefix) },
- +
- + { "user", &fpm_conf_set_string, WPO(user) },
- + { "group", &fpm_conf_set_string, WPO(group) },
- +
- + { "pm", &fpm_conf_set_pm, WPO(pm) },
- + { "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
- + { "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
- + { "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
- + { "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
- + { "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
- +
- + { "listen", &fpm_conf_set_string, WPO(listen_address) },
- + { "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
- + { "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
- + { "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
- + { "listen.group", &fpm_conf_set_string, WPO(listen_group) },
- + { "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
- +
- + { "access.log", &fpm_conf_set_string, WPO(access_log) },
- + { "access.format", &fpm_conf_set_string, WPO(access_format) },
- + { "slowlog", &fpm_conf_set_string, WPO(slowlog) },
- +
- + { "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
- + { "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
- + { "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
- + { "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
- +
- + { "chroot", &fpm_conf_set_string, WPO(chroot) },
- + { "chdir", &fpm_conf_set_string, WPO(chdir) },
- +
- + { "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) },
- +
- + { "diagnostics.status_path", &fpm_conf_set_string, WPO(diag_status_path) },
- + { "diagnostics.ping_path", &fpm_conf_set_string, WPO(diag_ping_path) },
- + { "diagnostics.ping_response", &fpm_conf_set_string, WPO(diag_ping_response) },
- +
- + /* Backward compatibility options, to be removed in the next major release */
- + { "ping.path", &fpm_conf_set_string, WPO(diag_ping_path) },
- + { "ping.response", &fpm_conf_set_string, WPO(diag_ping_response) },
- + { "pm.status_path", &fpm_conf_set_string, WPO(diag_status_path) },
- +
- { 0, 0, 0 }
- };
- @@ -120,22 +152,28 @@
- }
- /* }}} */
- +/// Expands the '$pool' token in a dynamically allocated string
- static int fpm_conf_expand_pool_name(char **value) {
- char *token;
- + assert(value);
- - if (!value || !*value) {
- - return 0;
- - }
- -
- - while ((token = strstr(*value, "$pool"))) {
- + while (*value && (token = strstr(*value, "$pool"))) {
- char *buf;
- - char *p1 = *value;
- char *p2 = token + strlen("$pool");
- - if (!current_wp || !current_wp->config || !current_wp->config->name) {
- +
- + /* If we are not in a pool, we cannot expand this name now */
- + if (!ini_current_config || !ini_current_config->name) {
- return -1;
- }
- +
- + /* "aaa$poolbbb" becomes "aaa\0oolbbb" */
- token[0] = '\0';
- - spprintf(&buf, 0, "%s%s%s", p1, current_wp->config->name, p2);
- +
- + /* Build a brand new string with the expanded token */
- + spprintf(&buf, 0, "%s%s%s", *value, ini_current_config->name, token + sizeof("$pool") - 1);
- +
- + /* Free the previous value and save the new one */
- + free(*value);
- *value = strdup(buf);
- efree(buf);
- }
- @@ -160,34 +198,34 @@
- static char *fpm_conf_set_string(zval *value, void **config, intptr_t offset) /* {{{ */
- {
- - char *new;
- - char **old = (char **) ((char *) *config + offset);
- - if (*old) {
- - return "it's already been defined. Can't do that twice.";
- + char **config_val = (char **) ((char *) *config + offset);
- +
- + /* Check if there is a previous value to deallocate */
- + if (*config_val) {
- + free(*config_val);
- }
- - new = strdup(Z_STRVAL_P(value));
- - if (!new) {
- + *config_val = strdup(Z_STRVAL_P(value));
- + if (!*config_val) {
- return "fpm_conf_set_string(): strdup() failed";
- }
- - if (fpm_conf_expand_pool_name(&new) == -1) {
- - return "Can't use '$pool' when the pool is not defined";
- + if (fpm_conf_expand_pool_name(config_val) != 0) {
- + return "can't use \"$pool\" when the pool is not defined";
- }
- - *old = new;
- return NULL;
- }
- /* }}} */
- static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset) /* {{{ */
- {
- - char *val = Z_STRVAL_P(value);
- - char *p;
- + char *p, *val = Z_STRVAL_P(value);
- - for(p=val; *p; p++) {
- - if ( p == val && *p == '-' ) continue;
- + /* FIXME: can we use strtol here and save this ridiculous for()? */
- + for (p = val; *p; p++) {
- + if (p == val && *p == '-') continue;
- if (*p < '0' || *p > '9') {
- - return "is not a valid number (greater or equal than zero)";
- + return "not a valid number";
- }
- }
- * (int *) ((char *) *config + offset) = atoi(val);
- @@ -205,7 +243,7 @@
- return "invalid time value";
- }
- - suffix = val[len-1];
- + suffix = val[len - 1];
- switch (suffix) {
- case 'm' :
- val[len-1] = '\0';
- @@ -343,25 +381,45 @@
- }
- /* }}} */
- -static void *fpm_worker_pool_config_alloc() /* {{{ */
- +static struct fpm_worker_pool_s *fpm_worker_pool_config_alloc() /* {{{ */
- +#define DUP_STR(fieldname) \
- + if (wp->config->fieldname) \
- + wp->config->fieldname = strdup(wp->config->fieldname);
- {
- struct fpm_worker_pool_s *wp;
- wp = fpm_worker_pool_alloc();
- -
- if (!wp) {
- - return 0;
- + return NULL;
- }
- wp->config = malloc(sizeof(struct fpm_worker_pool_config_s));
- -
- - if (!wp->config) {
- - return 0;
- + if (!wp->config) {
- + free(wp);
- + return NULL;
- }
- - memset(wp->config, 0, sizeof(struct fpm_worker_pool_config_s));
- - wp->config->listen_backlog = FPM_BACKLOG_DEFAULT;
- + /* Initialize this workers pool definition with the defaults */
- + memcpy(wp->config, &fpm_pool_default_config, sizeof(struct fpm_worker_pool_config_s));
- + wp->config->name = NULL;
- + DUP_STR(prefix);
- + DUP_STR(user);
- + DUP_STR(group);
- + DUP_STR(listen_address);
- + DUP_STR(listen_allowed_clients);
- + DUP_STR(listen_owner);
- + DUP_STR(listen_group);
- + DUP_STR(listen_mode);
- + DUP_STR(access_log);
- + DUP_STR(access_format);
- + DUP_STR(slowlog);
- + DUP_STR(chroot);
- + DUP_STR(chdir);
- + DUP_STR(diag_status_path);
- + DUP_STR(diag_ping_path);
- + DUP_STR(diag_ping_response);
- + /* Append this pool to the linked list */
- if (!fpm_worker_all_pools) {
- fpm_worker_all_pools = wp;
- } else {
- @@ -375,23 +433,15 @@
- }
- }
- - current_wp = wp;
- - return wp->config;
- + return wp;
- }
- +#undef DUP_STR
- /* }}} */
- int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */
- {
- struct key_value_s *kv, *kv_next;
- - free(wpc->name);
- - free(wpc->pm_status_path);
- - free(wpc->ping_path);
- - free(wpc->ping_response);
- - free(wpc->listen_address);
- - free(wpc->listen_owner);
- - free(wpc->listen_group);
- - free(wpc->listen_mode);
- for (kv = wpc->php_values; kv; kv = kv_next) {
- kv_next = kv->next;
- free(kv->key);
- @@ -410,16 +460,30 @@
- free(kv->value);
- free(kv);
- }
- - free(wpc->listen_allowed_clients);
- - free(wpc->user);
- - free(wpc->group);
- +
- + free(wpc->diag_ping_response);
- + free(wpc->diag_ping_path);
- + free(wpc->diag_status_path);
- +
- + free(wpc->chdir);
- free(wpc->chroot);
- - free(wpc->chdir);
- +
- free(wpc->slowlog);
- - free(wpc->prefix);
- + free(wpc->access_format);
- free(wpc->access_log);
- - free(wpc->access_format);
- + free(wpc->listen_mode);
- + free(wpc->listen_group);
- + free(wpc->listen_owner);
- + free(wpc->listen_allowed_clients);
- + free(wpc->listen_address);
- +
- + free(wpc->group);
- + free(wpc->user);
- +
- + free(wpc->prefix);
- + free(wpc->name);
- +
- return 0;
- }
- /* }}} */
- @@ -599,8 +663,8 @@
- }
- }
- - if (wp->config->ping_path && *wp->config->ping_path) {
- - char *ping = wp->config->ping_path;
- + if (wp->config->diag_ping_path) {
- + char *ping = wp->config->diag_ping_path;
- int i;
- if (*ping != '/') {
- @@ -613,46 +677,31 @@
- return -1;
- }
- - for (i=0; i<strlen(ping); i++) {
- + for (i = 0; i < strlen(ping); i++) {
- if (!isalnum(ping[i]) && ping[i] != '/' && ping[i] != '-' && ping[i] != '_' && ping[i] != '.') {
- zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' must containt only the following characters '[alphanum]/_-.'", wp->config->name, ping);
- return -1;
- }
- }
- -
- - if (!wp->config->ping_response) {
- - wp->config->ping_response = strdup("pong");
- - } else {
- - if (strlen(wp->config->ping_response) < 1) {
- - zlog(ZLOG_ERROR, "[pool %s] the ping response page '%s' is not long enough", wp->config->name, wp->config->ping_response);
- - return -1;
- - }
- - }
- - } else {
- - if (wp->config->ping_response) {
- - free(wp->config->ping_response);
- - wp->config->ping_response = NULL;
- - }
- }
- - if (wp->config->pm_status_path && *wp->config->pm_status_path) {
- + if (wp->config->diag_status_path) {
- int i;
- - char *status = wp->config->pm_status_path;
- - /* struct fpm_status_s fpm_status; */
- + char *status = wp->config->diag_status_path;
- if (*status != '/') {
- - zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must start with a '/'", wp->config->name, status);
- + zlog(ZLOG_ERROR, "[pool %s] the status path \"%s\" must start with a \"/\"", wp->config->name, status);
- return -1;
- }
- if (strlen(status) < 2) {
- - zlog(ZLOG_ERROR, "[pool %s] the status path '%s' is not long enough", wp->config->name, status);
- + zlog(ZLOG_ERROR, "[pool %s] the status path \"%s\" is not long enough", wp->config->name, status);
- return -1;
- }
- - for (i=0; i<strlen(status); i++) {
- + for (i = 0; i < strlen(status); i++) {
- if (!isalnum(status[i]) && status[i] != '/' && status[i] != '-' && status[i] != '_' && status[i] != '.') {
- - zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must contain only the following characters '[alphanum]/_-.'", wp->config->name, status);
- + zlog(ZLOG_ERROR, "[pool %s] the status path '%s' can contain only the following characters '[alphanum]/_-.'", wp->config->name, status);
- return -1;
- }
- }
- @@ -707,20 +756,21 @@
- }
- }
- }
- +
- if (!wp->config->chroot) {
- struct key_value_s *kv;
- char *options[] = FPM_PHP_INI_TO_EXPAND;
- char **p;
- for (kv = wp->config->php_values; kv; kv = kv->next) {
- - for (p=options; *p; p++) {
- + for (p = options; *p; p++) {
- if (!strcasecmp(kv->key, *p)) {
- fpm_evaluate_full_path(&kv->value, wp, NULL, 0);
- }
- }
- }
- for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
- - for (p=options; *p; p++) {
- + for (p = options; *p; p++) {
- if (!strcasecmp(kv->key, *p)) {
- fpm_evaluate_full_path(&kv->value, wp, NULL, 0);
- }
- @@ -772,7 +822,7 @@
- }
- /* }}} */
- -static int fpm_conf_post_process(TSRMLS_D) /* {{{ */
- +static int fpm_conf_post_process(int test_conf TSRMLS_DC) /* {{{ */
- {
- struct fpm_worker_pool_s *wp;
- @@ -786,15 +836,17 @@
- fpm_evaluate_full_path(&fpm_global_config.error_log, NULL, PHP_LOCALSTATEDIR, 0);
- - if (0 > fpm_stdio_open_error_log(0)) {
- - return -1;
- - }
- + if (!test_conf) {
- + if (fpm_stdio_open_error_log(0) != 0) {
- + return -1;
- + }
- - if (0 > fpm_log_open(0)) {
- - return -1;
- + if (fpm_log_open(0) != 0) {
- + return -1;
- + }
- }
- - if (0 > fpm_conf_process_all_pools()) {
- + if (fpm_conf_process_all_pools() != 0) {
- return -1;
- }
- @@ -802,7 +854,7 @@
- if (!wp->config->access_log || !*wp->config->access_log) {
- continue;
- }
- - if (0 > fpm_log_write(wp->config->access_format TSRMLS_CC)) {
- + if (fpm_log_write(wp->config->access_format TSRMLS_CC) != 0) {
- zlog(ZLOG_ERROR, "[pool %s] wrong format for access.format '%s'", wp->config->name, wp->config->access_format);
- return -1;
- }
- @@ -850,11 +902,11 @@
- return;
- }
- - for(i=0; i<g.gl_pathc; i++) {
- + for(i = 0; i < g.gl_pathc; i++) {
- int len = strlen(g.gl_pathv[i]);
- if (len < 1) continue;
- if (g.gl_pathv[i][len - 1] == '/') continue; /* don't parse directories */
- - if (0 > fpm_conf_load_ini_file(g.gl_pathv[i] TSRMLS_CC)) {
- + if (!fpm_conf_load_ini_file(g.gl_pathv[i] TSRMLS_CC)) {
- zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, ini_lineno);
- *error = 1;
- efree(filename);
- @@ -864,7 +916,7 @@
- globfree(&g);
- }
- #else /* HAVE_GLOB */
- - if (0 > fpm_conf_load_ini_file(inc TSRMLS_CC)) {
- + if (!fpm_conf_load_ini_file(inc TSRMLS_CC)) {
- zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", inc, filename, ini_lineno);
- *error = 1;
- efree(filename);
- @@ -876,50 +928,72 @@
- }
- /* }}} */
- +/**
- + * Callback for zend_parse_ini_string() for ZEND_INI_PARSER_SECTION type
- + */
- static void fpm_conf_ini_parser_section(zval *section, void *arg TSRMLS_DC) /* {{{ */
- {
- struct fpm_worker_pool_s *wp;
- struct fpm_worker_pool_config_s *config;
- int *error = (int *)arg;
- - /* switch to global conf */
- + /* Switch to global conf */
- if (!strcasecmp(Z_STRVAL_P(section), "global")) {
- - current_wp = NULL;
- + ini_current_config = NULL;
- return;
- }
- - for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
- - if (!wp->config) continue;
- - if (!wp->config->name) continue;
- - if (!strcasecmp(wp->config->name, Z_STRVAL_P(section))) {
- - /* Found a wp with the same name. Bring it back */
- - current_wp = wp;
- + if (!strcasecmp(Z_STRVAL_P(section), "defaults")) {
- + /* If there is a defaults section it must be before any
- + * workers definition */
- + if (fpm_worker_all_pools != NULL) {
- + zlog(ZLOG_ERROR, "[%s:%d] Defaults section must be before any workers pool definition", ini_filename, ini_lineno);
- + *error = 1;
- return;
- }
- - }
- - /* it's a new pool */
- - config = (struct fpm_worker_pool_config_s *)fpm_worker_pool_config_alloc();
- - if (!current_wp || !config) {
- - zlog(ZLOG_ERROR, "[%s:%d] Unable to alloc a new WorkerPool for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
- - *error = 1;
- + ini_current_config = &fpm_pool_default_config;
- return;
- }
- - config->name = strdup(Z_STRVAL_P(section));
- - if (!config->name) {
- - zlog(ZLOG_ERROR, "[%s:%d] Unable to alloc memory for configuration name for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
- - *error = 1;
- - return;
- +
- + /* Search for a wp with the same name and bring it back in case */
- + for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
- + if (wp->config->name &&
- + !strcasecmp(wp->config->name, Z_STRVAL_P(section))) {
- + break;
- + }
- }
- +
- + /* It's a new pool */
- + if (!wp) {
- + wp = fpm_worker_pool_config_alloc();
- + if (!wp) {
- + zlog(ZLOG_ERROR, "[%s:%d] Unable to allocate a new WorkerPool for \"%s\"", ini_filename, ini_lineno, Z_STRVAL_P(section));
- + *error = 1;
- + return;
- + }
- +
- + wp->config->name = strdup(Z_STRVAL_P(section));
- + if (!wp->config->name) {
- + zlog(ZLOG_ERROR, "[%s:%d] Unable to allocate memory for worker \"%s\"", ini_filename, ini_lineno, Z_STRVAL_P(section));
- + *error = 1;
- + return;
- + }
- + }
- +
- + ini_current_config = wp->config;
- }
- /* }}} */
- +/**
- + * Callback for zend_parse_ini_string() for ZEND_INI_PARSER_ENTRY type
- + */
- static void fpm_conf_ini_parser_entry(zval *name, zval *value, void *arg TSRMLS_DC) /* {{{ */
- {
- - struct ini_value_parser_s *parser;
- + struct ini_value_parser_s *opt;
- + int *error = (int *) arg;
- void *config = NULL;
- - int *error = (int *)arg;
- if (!value) {
- zlog(ZLOG_ERROR, "[%s:%d] value is NULL for a ZEND_INI_PARSER_ENTRY", ini_filename, ini_lineno);
- *error = 1;
- @@ -928,7 +1002,7 @@
- if (!strcmp(Z_STRVAL_P(name), "include")) {
- if (ini_include) {
- - zlog(ZLOG_ERROR, "[%s:%d] two includes at the same time !", ini_filename, ini_lineno);
- + zlog(ZLOG_ERROR, "[%s:%d] two includes at the same time!", ini_filename, ini_lineno);
- *error = 1;
- return;
- }
- @@ -936,41 +1010,38 @@
- return;
- }
- - if (!current_wp) { /* we are in the global section */
- - parser = ini_fpm_global_options;
- + if (!ini_current_config) {
- + /* We are in the global section */
- + opt = ini_fpm_global_options;
- config = &fpm_global_config;
- } else {
- - parser = ini_fpm_pool_options;
- - config = current_wp->config;
- + /* We are in a pool section or the defaults section */
- + opt = ini_fpm_pool_options;
- + config = ini_current_config;
- }
- - for (;parser->name; parser++) {
- - if (!strcasecmp(parser->name, Z_STRVAL_P(name))) {
- - char *ret;
- - if (!parser->parser) {
- - zlog(ZLOG_ERROR, "[%s:%d] the parser for entry '%s' is not defined", ini_filename, ini_lineno, parser->name);
- + /* Find our option */
- + while (opt->name) {
- + if (!strcasecmp(opt->name, Z_STRVAL_P(name))) {
- + char *errmsg = opt->parser(value, &config, opt->offset);
- + if (errmsg) {
- + zlog(ZLOG_ERROR, "[%s:%d] unable to parse value for entry '%s': %s", ini_filename, ini_lineno, opt->name, errmsg);
- *error = 1;
- - return;
- }
- -
- - ret = parser->parser(value, &config, parser->offset);
- - if (ret) {
- - zlog(ZLOG_ERROR, "[%s:%d] unable to parse value for entry '%s': %s", ini_filename, ini_lineno, parser->name, ret);
- - *error = 1;
- - return;
- - }
- -
- - /* all is good ! */
- return;
- }
- + opt++;
- }
- /* nothing has been found if we got here */
- - zlog(ZLOG_ERROR, "[%s:%d] unknown entry '%s'", ini_filename, ini_lineno, Z_STRVAL_P(name));
- + zlog(ZLOG_ERROR, "[%s:%d] unknown entry \"%s\"", ini_filename, ini_lineno, Z_STRVAL_P(name));
- *error = 1;
- }
- /* }}} */
- +/**
- + * Callback for fpm_conf_ini_parser_entry() for ZEND_INI_PARSER_POP_ENTRY type
- + */
- static void fpm_conf_ini_parser_array(zval *name, zval *key, zval *value, void *arg TSRMLS_DC) /* {{{ */
- {
- int *error = (int *)arg;
- @@ -982,7 +1053,7 @@
- *error = 1;
- return;
- }
- - if (!current_wp || !current_wp->config) {
- + if (!ini_current_config) {
- zlog(ZLOG_ERROR, "[%s:%d] Array are not allowed in the global section", ini_filename, ini_lineno);
- *error = 1;
- return;
- @@ -994,7 +1065,7 @@
- *error = 1;
- return;
- }
- - config = (char *)current_wp->config + WPO(env);
- + config = (char *) ini_current_config + WPO(env);
- err = fpm_conf_set_array(key, value, &config, 0);
- } else if (!strcmp("php_value", Z_STRVAL_P(name))) {
- @@ -1003,7 +1074,7 @@
- *error = 1;
- return;
- }
- - config = (char *)current_wp->config + WPO(php_values);
- + config = (char *) ini_current_config + WPO(php_values);
- err = fpm_conf_set_array(key, value, &config, 0);
- } else if (!strcmp("php_admin_value", Z_STRVAL_P(name))) {
- @@ -1012,15 +1083,15 @@
- *error = 1;
- return;
- }
- - config = (char *)current_wp->config + WPO(php_admin_values);
- + config = (char *) ini_current_config + WPO(php_admin_values);
- err = fpm_conf_set_array(key, value, &config, 0);
- } else if (!strcmp("php_flag", Z_STRVAL_P(name))) {
- - config = (char *)current_wp->config + WPO(php_values);
- + config = (char *) ini_current_config + WPO(php_values);
- err = fpm_conf_set_array(key, value, &config, 1);
- } else if (!strcmp("php_admin_flag", Z_STRVAL_P(name))) {
- - config = (char *)current_wp->config + WPO(php_admin_values);
- + config = (char *) ini_current_config + WPO(php_admin_values);
- err = fpm_conf_set_array(key, value, &config, 1);
- } else {
- @@ -1037,28 +1108,36 @@
- }
- /* }}} */
- +/**
- + * Callback for zend_parse_ini_string()
- + *
- + * It's main purpose is to route the callback to the respective ini entry type handler
- + */
- static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC) /* {{{ */
- {
- - int *error;
- + int *error = (int *) arg;
- + // FIXME: is it possible at all?
- if (!arg1 || !arg) return;
- - error = (int *)arg;
- - if (*error) return; /* We got already an error. Switch to the end. */
- - switch(callback_type) {
- + /* Check if we already got an error */
- + if (*error) {
- + return;
- + }
- +
- + switch (callback_type) {
- case ZEND_INI_PARSER_ENTRY:
- fpm_conf_ini_parser_entry(arg1, arg2, error TSRMLS_CC);
- - break;;
- + break;
- case ZEND_INI_PARSER_SECTION:
- fpm_conf_ini_parser_section(arg1, error TSRMLS_CC);
- - break;;
- + break;
- case ZEND_INI_PARSER_POP_ENTRY:
- fpm_conf_ini_parser_array(arg1, arg3, arg2, error TSRMLS_CC);
- - break;;
- + break;
- default:
- zlog(ZLOG_ERROR, "[%s:%d] Unknown INI syntax", ini_filename, ini_lineno);
- *error = 1;
- - break;;
- }
- }
- /* }}} */
- @@ -1066,47 +1145,45 @@
- int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
- {
- int error = 0;
- - char buf[1024+1];
- - int fd, n;
- - int nb_read = 1;
- - char c = '*';
- + char buf[1024];
- + FILE *fd;
- + int tmp;
- + int retval = 0;
- + assert(filename);
- - int ret = 1;
- -
- - if (!filename || !filename[0]) {
- - zlog(ZLOG_ERROR, "Configuration file is empty");
- + if (!filename[0]) {
- + zlog(ZLOG_ERROR, "Empty configuration file name");
- return -1;
- }
- - fd = open(filename, O_RDONLY, 0);
- - if (fd < 0) {
- - zlog(ZLOG_ERROR, "Unable to open file '%s', errno=%d", filename, errno);
- + fd = fopen(filename, "r");
- + if (fd == NULL) {
- + zlog(ZLOG_ERROR, "Unable to open FPM config file \"%s\": %s", filename, strerror(errno));
- return -1;
- }
- - if (ini_recursion++ > 4) {
- - zlog(ZLOG_ERROR, "You can include more than 5 files recusively");
- + if (ini_recursion++ >= FPM_CONF_MAX_RECURSION_LEVEL) {
- + zlog(ZLOG_ERROR, "Config file inclusion depth limit reached, recursion?");
- return -1;
- }
- ini_lineno = 0;
- - while (nb_read > 0) {
- - int tmp;
- - memset(buf, 0, sizeof(char) * (1024 + 1));
- - for (n=0; n<1024 && (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) {
- - buf[n] = c;
- - }
- - buf[n++] = '\n';
- + while (!feof(fd)) {
- + fgets(buf, sizeof(buf), fd);
- ini_lineno++;
- ini_filename = filename;
- - tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC);
- +
- + tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) fpm_conf_ini_parser, &error TSRMLS_CC);
- ini_filename = filename;
- +
- if (error || tmp == FAILURE) {
- - if (ini_include) free(ini_include);
- - ini_recursion--;
- - close(fd);
- - return -1;
- + if (ini_include) {
- + free(ini_include);
- + }
- + retval = -1;
- + goto out;
- }
- +
- if (ini_include) {
- char *tmp = ini_include;
- ini_include = NULL;
- @@ -1114,80 +1191,97 @@
- fpm_conf_ini_parser_include(tmp, &error TSRMLS_CC);
- if (error) {
- free(tmp);
- - ini_recursion--;
- - close(fd);
- - return -1;
- +
- + retval = -1;
- + goto out;
- }
- free(tmp);
- }
- }
- + out:
- ini_recursion--;
- - close(fd);
- - return ret;
- + fclose(fd);
- + return retval;
- }
- /* }}} */
- static void fpm_conf_dump() /* {{{ */
- {
- struct fpm_worker_pool_s *wp;
- + int emergency_restart_threshold;
- + int emergency_restart_interval;
- + int process_control_timeout;
- + int daemonize;
- + char *pid_file;
- + char *error_log;
- + int rlimit_files;
- + int rlimit_core;
- - zlog(ZLOG_NOTICE, "[General]");
- - zlog(ZLOG_NOTICE, "\tpid = %s", STR2STR(fpm_global_config.pid_file));
- - zlog(ZLOG_NOTICE, "\tdaemonize = %s", BOOL2STR(fpm_global_config.daemonize));
- - zlog(ZLOG_NOTICE, "\terror_log = %s", STR2STR(fpm_global_config.error_log));
- - zlog(ZLOG_NOTICE, "\tlog_level = %s", zlog_get_level_name());
- - 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, "[global]");
- + zlog(ZLOG_NOTICE, "emergency_restart_threshold = %d", fpm_global_config.emergency_restart_threshold);
- + zlog(ZLOG_NOTICE, "emergency_restart_interval = %ds", fpm_global_config.emergency_restart_interval);
- + zlog(ZLOG_NOTICE, "process_control_timeout = %ds", fpm_global_config.process_control_timeout);
- + zlog(ZLOG_NOTICE, "daemonize = %s", BOOL2STR(fpm_global_config.daemonize));
- + zlog(ZLOG_NOTICE, "pid_file = %s", STR2STR(fpm_global_config.pid_file));
- + zlog(ZLOG_NOTICE, "error_log = %s", STR2STR(fpm_global_config.error_log));
- + zlog(ZLOG_NOTICE, "rlimit_files = %d", fpm_global_config.rlimit_files);
- + zlog(ZLOG_NOTICE, "rlimit_core = %d", fpm_global_config.rlimit_core);
- + zlog(ZLOG_NOTICE, "log_level = %s", zlog_get_level_name());
- zlog(ZLOG_NOTICE, " ");
- for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
- struct key_value_s *kv;
- - if (!wp->config) continue;
- - zlog(ZLOG_NOTICE, "[%s]", STR2STR(wp->config->name));
- - zlog(ZLOG_NOTICE, "\tprefix = %s", STR2STR(wp->config->prefix));
- - zlog(ZLOG_NOTICE, "\tuser = %s", STR2STR(wp->config->user));
- - zlog(ZLOG_NOTICE, "\tgroup = %s", STR2STR(wp->config->group));
- - zlog(ZLOG_NOTICE, "\tchroot = %s", STR2STR(wp->config->chroot));
- - zlog(ZLOG_NOTICE, "\tchdir = %s", STR2STR(wp->config->chdir));
- - zlog(ZLOG_NOTICE, "\tlisten = %s", STR2STR(wp->config->listen_address));
- - zlog(ZLOG_NOTICE, "\tlisten.backlog = %d", wp->config->listen_backlog);
- - zlog(ZLOG_NOTICE, "\tlisten.owner = %s", STR2STR(wp->config->listen_owner));
- - zlog(ZLOG_NOTICE, "\tlisten.group = %s", STR2STR(wp->config->listen_group));
- - zlog(ZLOG_NOTICE, "\tlisten.mode = %s", STR2STR(wp->config->listen_mode));
- - zlog(ZLOG_NOTICE, "\tlisten.allowed_clients = %s", STR2STR(wp->config->listen_allowed_clients));
- - zlog(ZLOG_NOTICE, "\tpm = %s", PM2STR(wp->config->pm));
- - zlog(ZLOG_NOTICE, "\tpm.max_children = %d", wp->config->pm_max_children);
- - zlog(ZLOG_NOTICE, "\tpm.max_requests = %d", wp->config->pm_max_requests);
- - zlog(ZLOG_NOTICE, "\tpm.start_servers = %d", wp->config->pm_start_servers);
- - zlog(ZLOG_NOTICE, "\tpm.min_spare_servers = %d", wp->config->pm_min_spare_servers);
- - zlog(ZLOG_NOTICE, "\tpm.max_spare_servers = %d", wp->config->pm_max_spare_servers);
- - zlog(ZLOG_NOTICE, "\tpm.status_path = %s", STR2STR(wp->config->pm_status_path));
- - zlog(ZLOG_NOTICE, "\tping.path = %s", STR2STR(wp->config->ping_path));
- - zlog(ZLOG_NOTICE, "\tping.response = %s", STR2STR(wp->config->ping_response));
- - zlog(ZLOG_NOTICE, "\taccess.log = %s", STR2STR(wp->config->access_log));
- - zlog(ZLOG_NOTICE, "\taccess.format = %s", STR2STR(wp->config->access_format));
- - zlog(ZLOG_NOTICE, "\tcatch_workers_output = %s", BOOL2STR(wp->config->catch_workers_output));
- - zlog(ZLOG_NOTICE, "\trequest_terminate_timeout = %ds", wp->config->request_terminate_timeout);
- - zlog(ZLOG_NOTICE, "\trequest_slowlog_timeout = %ds", wp->config->request_slowlog_timeout);
- - zlog(ZLOG_NOTICE, "\tslowlog = %s", STR2STR(wp->config->slowlog));
- - zlog(ZLOG_NOTICE, "\trlimit_files = %d", wp->config->rlimit_files);
- - zlog(ZLOG_NOTICE, "\trlimit_core = %d", wp->config->rlimit_core);
- + zlog(ZLOG_NOTICE, "[%s]", STR2STR(wp->config->name));
- + zlog(ZLOG_NOTICE, "prefix = %s", STR2STR(wp->config->prefix));
- +
- + zlog(ZLOG_NOTICE, "user = %s", STR2STR(wp->config->user));
- + zlog(ZLOG_NOTICE, "group = %s", STR2STR(wp->config->group));
- +
- + zlog(ZLOG_NOTICE, "listen = %s", STR2STR(wp->config->listen_address));
- + zlog(ZLOG_NOTICE, "listen.backlog = %d", wp->config->listen_backlog);
- + zlog(ZLOG_NOTICE, "listen.owner = %s", STR2STR(wp->config->listen_owner));
- + zlog(ZLOG_NOTICE, "listen.group = %s", STR2STR(wp->config->listen_group));
- + zlog(ZLOG_NOTICE, "listen.mode = %s", STR2STR(wp->config->listen_mode));
- + zlog(ZLOG_NOTICE, "listen.allowed_clients = %s", STR2STR(wp->config->listen_allowed_clients));
- +
- + zlog(ZLOG_NOTICE, "pm = %s", PM2STR(wp->config->pm));
- + zlog(ZLOG_NOTICE, "pm.max_children = %d", wp->config->pm_max_children);
- + zlog(ZLOG_NOTICE, "pm.start_servers = %d", wp->config->pm_start_servers);
- + zlog(ZLOG_NOTICE, "pm.min_spare_servers = %d", wp->config->pm_min_spare_servers);
- + zlog(ZLOG_NOTICE, "pm.max_spare_servers = %d", wp->config->pm_max_spare_servers);
- + zlog(ZLOG_NOTICE, "pm.max_requests = %d", wp->config->pm_max_requests);
- +
- + zlog(ZLOG_NOTICE, "access.log = %s", STR2STR(wp->config->access_log));
- + zlog(ZLOG_NOTICE, "access.format = %s", STR2STR(wp->config->access_format));
- + zlog(ZLOG_NOTICE, "slowlog = %s", STR2STR(wp->config->slowlog));
- +
- + zlog(ZLOG_NOTICE, "request_terminate_timeout = %ds", wp->config->request_terminate_timeout);
- + zlog(ZLOG_NOTICE, "request_slowlog_timeout = %ds", wp->config->request_slowlog_timeout);
- + zlog(ZLOG_NOTICE, "rlimit_files = %d", wp->config->rlimit_files);
- + zlog(ZLOG_NOTICE, "rlimit_core = %d", wp->config->rlimit_core);
- +
- + zlog(ZLOG_NOTICE, "chroot = %s", STR2STR(wp->config->chroot));
- + zlog(ZLOG_NOTICE, "chdir = %s", STR2STR(wp->config->chdir));
- +
- + zlog(ZLOG_NOTICE, "catch_workers_output = %s", BOOL2STR(wp->config->catch_workers_output));
- +
- + zlog(ZLOG_NOTICE, "diagnostics.status_path = %s", STR2STR(wp->config->diag_status_path));
- + zlog(ZLOG_NOTICE, "diagnostics.ping_path = %s", STR2STR(wp->config->diag_ping_path));
- + zlog(ZLOG_NOTICE, "diagnostics.ping_response = %s", STR2STR(wp->config->diag_ping_response));
- +
- for (kv = wp->config->env; kv; kv = kv->next) {
- - zlog(ZLOG_NOTICE, "\tenv[%s] = %s", kv->key, kv->value);
- + zlog(ZLOG_NOTICE, "env[%s] = %s", kv->key, kv->value);
- }
- for (kv = wp->config->php_values; kv; kv = kv->next) {
- - zlog(ZLOG_NOTICE, "\tphp_value[%s] = %s", kv->key, kv->value);
- + zlog(ZLOG_NOTICE, "php_value[%s] = %s", kv->key, kv->value);
- }
- for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
- - zlog(ZLOG_NOTICE, "\tphp_admin_value[%s] = %s", kv->key, kv->value);
- + zlog(ZLOG_NOTICE, "php_admin_value[%s] = %s", kv->key, kv->value);
- }
- zlog(ZLOG_NOTICE, " ");
- }
- @@ -1196,7 +1290,6 @@
- int fpm_conf_init_main(int test_conf) /* {{{ */
- {
- - int ret;
- TSRMLS_FETCH();
- if (fpm_globals.prefix && *fpm_globals.prefix) {
- @@ -1233,14 +1326,11 @@
- }
- }
- - ret = fpm_conf_load_ini_file(fpm_globals.config TSRMLS_CC);
- -
- - if (0 > ret) {
- - zlog(ZLOG_ERROR, "failed to load configuration file '%s'", fpm_globals.config);
- + if (fpm_conf_load_ini_file(fpm_globals.config TSRMLS_CC) != 0) {
- return -1;
- }
- - if (0 > fpm_conf_post_process(TSRMLS_C)) {
- + if (fpm_conf_post_process(test_conf TSRMLS_CC) != 0) {
- zlog(ZLOG_ERROR, "failed to post process the configuration");
- return -1;
- }
- @@ -1254,7 +1344,7 @@
- return -1;
- }
- - if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_conf_cleanup, 0)) {
- + if (fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_conf_cleanup, 0) != 0) {
- return -1;
- }
- Index: sapi/fpm/fpm/fpm_env.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_env.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_env.c (working copy)
- @@ -269,7 +269,7 @@
- #endif
- spprintf(&title, 0, "master process (%s)", fpm_globals.config);
- - fpm_env_setproctitle(title);
- + fpm_env_setproctitle(title);
- efree(title);
- return 0;
- }
- Index: sapi/fpm/fpm/fpm_conf.h
- ===================================================================
- --- sapi/fpm/fpm/fpm_conf.h (revision 312829)
- +++ sapi/fpm/fpm/fpm_conf.h (working copy)
- @@ -9,10 +9,9 @@
- #include "php.h"
- #define FPM_CONF_MAX_PONG_LENGTH 64
- +#define MAX_CONF_RECURSION_LEVEL 5
- +#define FPM_CONF_MAX_RECURSION_LEVEL 5
- -#define STR2STR(a) (a ? a : "undefined")
- -#define BOOL2STR(a) (a ? "yes" : "no")
- -#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
- struct key_value_s;
- @@ -38,33 +37,42 @@
- struct fpm_worker_pool_config_s {
- char *name;
- char *prefix;
- +
- char *user;
- char *group;
- - char *chroot;
- - char *chdir;
- +
- + char *listen_address;
- + int listen_backlog;
- + char *listen_allowed_clients;
- + char *listen_owner;
- + char *listen_group;
- + char *listen_mode;
- +
- + int pm;
- + int pm_max_children;
- + int pm_start_servers;
- + int pm_min_spare_servers;
- + int pm_max_spare_servers;
- + int pm_max_requests;
- +
- int request_terminate_timeout;
- int request_slowlog_timeout;
- - char *slowlog;
- int rlimit_files;
- int rlimit_core;
- +
- + char *chroot;
- + char *chdir; // FIXME: do we really need this?
- +
- int catch_workers_output;
- - int pm;
- - int pm_max_children;
- - char *pm_status_path;
- - int pm_max_requests;
- - int pm_start_servers;
- - int pm_min_spare_servers;
- - int pm_max_spare_servers;
- - char *ping_path;
- - char *ping_response;
- +
- + char *diag_status_path;
- + char *diag_ping_path;
- + char *diag_ping_response;
- +
- char *access_log;
- char *access_format;
- - char *listen_address;
- - int listen_backlog;
- - char *listen_owner;
- - char *listen_group;
- - char *listen_mode;
- - char *listen_allowed_clients;
- + char *slowlog;
- +
- struct key_value_s *env;
- struct key_value_s *php_admin_values;
- struct key_value_s *php_values;
- @@ -76,7 +84,10 @@
- intptr_t offset;
- };
- -enum { PM_STYLE_STATIC = 1, PM_STYLE_DYNAMIC = 2 };
- +enum {
- + PM_STYLE_STATIC = 1,
- + PM_STYLE_DYNAMIC = 2
- +};
- int fpm_conf_init_main(int test_conf);
- int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc);
- @@ -84,4 +95,3 @@
- int fpm_conf_unlink_pid();
- #endif
- -
- Index: sapi/fpm/fpm/fpm_signals.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_signals.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_signals.c (working copy)
- @@ -201,12 +201,11 @@
- sigfillset(&act.sa_mask);
- if (0 > sigaction(SIGTERM, &act, 0) ||
- - 0 > sigaction(SIGINT, &act, 0) ||
- - 0 > sigaction(SIGUSR1, &act, 0) ||
- - 0 > sigaction(SIGUSR2, &act, 0) ||
- - 0 > sigaction(SIGCHLD, &act, 0) ||
- - 0 > sigaction(SIGQUIT, &act, 0)) {
- -
- + 0 > sigaction(SIGINT, &act, 0) ||
- + 0 > sigaction(SIGUSR1, &act, 0) ||
- + 0 > sigaction(SIGUSR2, &act, 0) ||
- + 0 > sigaction(SIGCHLD, &act, 0) ||
- + 0 > sigaction(SIGQUIT, &act, 0)) {
- zlog(ZLOG_SYSERROR, "sigaction() failed");
- return -1;
- }
- @@ -230,12 +229,11 @@
- close(sp[1]);
- if (0 > sigaction(SIGTERM, &act_dfl, 0) ||
- - 0 > sigaction(SIGINT, &act_dfl, 0) ||
- - 0 > sigaction(SIGUSR1, &act_dfl, 0) ||
- - 0 > sigaction(SIGUSR2, &act_dfl, 0) ||
- - 0 > sigaction(SIGCHLD, &act_dfl, 0) ||
- - 0 > sigaction(SIGQUIT, &act, 0)) {
- -
- + 0 > sigaction(SIGINT, &act_dfl, 0) ||
- + 0 > sigaction(SIGUSR1, &act_dfl, 0) ||
- + 0 > sigaction(SIGUSR2, &act_dfl, 0) ||
- + 0 > sigaction(SIGCHLD, &act_dfl, 0) ||
- + 0 > sigaction(SIGQUIT, &act, 0)) {
- zlog(ZLOG_SYSERROR, "sigaction() failed");
- return -1;
- }
- @@ -248,4 +246,3 @@
- return sp[0];
- }
- /* }}} */
- -
- Index: sapi/fpm/fpm/fpm_log.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_log.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_log.c (working copy)
- @@ -33,9 +33,8 @@
- int fpm_log_open(int reopen) /* {{{ */
- {
- struct fpm_worker_pool_s *wp;
- - int ret = 1;
- -
- - int fd;
- + int fd, ret = 1;
- +
- for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
- if (!wp->config->access_log) {
- continue;
- Index: sapi/fpm/fpm/fpm_scoreboard.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_scoreboard.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_scoreboard.c (working copy)
- @@ -57,7 +57,7 @@
- return -1;
- }
- wp->scoreboard->nprocs = wp->config->pm_max_children;
- - for (i=0; i<wp->scoreboard->nprocs; i++) {
- + for (i = 0; i < wp->scoreboard->nprocs; i++) {
- wp->scoreboard->procs[i] = fpm_shm_alloc(sizeof(struct fpm_scoreboard_proc_s));
- if (!wp->scoreboard->procs[i]) {
- return -1;
- @@ -69,7 +69,7 @@
- wp->scoreboard->start_epoch = time(NULL);
- strlcpy(wp->scoreboard->pool, wp->config->name, sizeof(wp->scoreboard->pool));
- }
- - return 0;
- + return 0;
- }
- /* }}} */
- @@ -83,7 +83,6 @@
- return;
- }
- -
- fpm_spinlock(&scoreboard->lock, 0);
- if (action == FPM_SCOREBOARD_ACTION_SET) {
- if (idle >= 0) {
- Index: sapi/fpm/fpm/fpm_main.c
- ===================================================================
- --- sapi/fpm/fpm/fpm_main.c (revision 312829)
- +++ sapi/fpm/fpm/fpm_main.c (working copy)
- @@ -674,12 +674,13 @@
- if (CGIG(fix_pathinfo)) {
- char *script_name = SG(request_info).request_uri;
- unsigned int script_name_len = script_name ? strlen(script_name) : 0;
- - char *path_info = sapi_cgibin_getenv("PATH_INFO", sizeof("PATH_INFO")-1 TSRMLS_CC);
- + char *path_info = sapi_cgibin_getenv("PATH_INFO", sizeof("PATH_INFO") - 1 TSRMLS_CC);
- unsigned int path_info_len = path_info ? strlen(path_info) : 0;
- php_self_len = script_name_len + path_info_len;
- php_self = emalloc(php_self_len + 1);
- + /* Concat script_name and path_info into php_self */
- if (script_name) {
- memcpy(php_self, script_name, script_name_len + 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement