com php-src: add fpm_get_configuration() and FPM config to MINFO: sapi/fpm/fpm/fpm.c sapi/fpm/fpm/fp m_children.c sapi/fpm/fpm/fpm_children.h
sapi/fpm/f pm/fpm_main.c
| From: | Antony Dovgal | Date: | Tue, 17 Dec 2013 14:05:11 +0000 |
| Subject: | com php-src: add fpm_get_configuration() and FPM config to MINFO: sapi/fpm/fpm/fpm.c sapi/fpm/fpm/fp m_children.c sapi/fpm/fpm/fpm_children.h sapi/fpm/f pm/fpm_main.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76628@lists.php.net to get a copy of this message | ||
Commit: b625c2b6e41e1cb179c0bb4bd9b22ab0f3e36f9f
Author: Antony Dovgal <tony2001@php.net> Tue, 17 Dec 2013 18:05:11 +0400
Parents: edbfc32742686f888a7220b49cd34644745398b9
Branches: badoo-5.5_mysqlnd
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b625c2b6e41e1cb179c0bb4bd9b22ab0f3e36f9f
Log:
add fpm_get_configuration() and FPM config to MINFO
Changed paths:
M sapi/fpm/fpm/fpm.c
M sapi/fpm/fpm/fpm_children.c
M sapi/fpm/fpm/fpm_children.h
M sapi/fpm/fpm/fpm_main.c
diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index b866f37..4d3252a 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -114,8 +114,6 @@ int fpm_run(int *max_requests) /* {{{ */ run_child: /* only workers reach this point */ - fpm_cleanups_run(FPM_CLEANUP_CHILD); - *max_requests = fpm_globals.max_requests; return fpm_globals.listening_socket; } diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index 45cc075..c063820 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -34,6 +34,8 @@ static time_t *last_faults; static int fault; +struct fpm_child_s *this_child = NULL; + static void fpm_children_cleanup(int which, void *arg) /* {{{ */ { free(last_faults); @@ -56,7 +58,7 @@ static struct fpm_child_s *fpm_child_alloc() /* {{{ */ } /* }}} */ -static void fpm_child_free(struct fpm_child_s *child) /* {{{ */ +void fpm_child_free(struct fpm_child_s *child) /* {{{ */ { free(child); } @@ -347,7 +349,6 @@ static void fpm_child_resources_use(struct fpm_child_s *child) /* {{{ */ fpm_scoreboard_child_use(child->wp->scoreboard, child->scoreboard_i, getpid()); fpm_stdio_child_use_pipes(child); - fpm_child_free(child); } /* }}} */ @@ -404,6 +405,7 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to case 0 : fpm_child_resources_use(child); fpm_globals.is_child = 1; + this_child = child; fpm_child_init(wp); return 0; diff --git a/sapi/fpm/fpm/fpm_children.h b/sapi/fpm/fpm/fpm_children.h index 9c79f23..f43112d 100644 --- a/sapi/fpm/fpm/fpm_children.h +++ b/sapi/fpm/fpm/fpm_children.h @@ -16,6 +16,9 @@ int fpm_children_free(struct fpm_child_s *child); void fpm_children_bury(); int fpm_children_init_main(); int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug); +void fpm_child_free(struct fpm_child_s *child); + +extern struct fpm_child_s *this_child; struct fpm_child_s; diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 043e0e0..c405449 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -104,8 +104,10 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include "fpm_request.h" #include "fpm_status.h" #include "fpm_conf.h" +#include "fpm_children.h" #include "fpm_php.h" #include "fpm_log.h" +#include "fpm_cleanup.h" #include "zlog.h" #ifndef PHP_WIN32 @@ -1493,14 +1495,130 @@ static PHP_MSHUTDOWN_FUNCTION(cgi) } /* }}} */ +#define FPM_INFO_ROW_INT(name) \ + sprintf(buf, "%d", fpm_global_config.name); \ + php_info_print_table_row(2, #name, buf); + +#define FPM_POOL_INFO_STR(name) \ + php_info_print_table_row(2, #name, this_child->wp->config->name); + +#define FPM_POOL_INFO_INT(name) \ + sprintf(buf, "%d", this_child->wp->config->name); \ + php_info_print_table_row(2, #name, buf); + /* {{{ PHP_MINFO_FUNCTION */ static PHP_MINFO_FUNCTION(cgi) { + char buf[256]; + php_info_print_table_start(); + php_info_print_table_header(2, "PHP-FPM global configuration", "Value"); php_info_print_table_row(2, "php-fpm", "active"); + php_info_print_table_row(2, "pid_file", fpm_global_config.pid_file); + php_info_print_table_row(2, "error_log", fpm_global_config.error_log); + +#ifdef HAVE_SYSLOG_H + php_info_print_table_row(2, "syslog_ident", fpm_global_config.syslog_ident); + + sprintf(buf, "%d", fpm_global_config.syslog_facility); + php_info_print_table_row(2, "syslog_facility", buf); +#endif + + switch (fpm_global_config.log_level) { + case ZLOG_DEBUG: + sprintf(buf, "debug"); + break; + case ZLOG_NOTICE: + sprintf(buf, "notice"); + break; + case ZLOG_WARNING: + sprintf(buf, "warning"); + break; + case ZLOG_ERROR: + sprintf(buf, "error"); + break; + case ZLOG_ALERT: + sprintf(buf, "alert"); + break; + default: + sprintf(buf, "unknown log_level value (%d)", fpm_global_config.log_level); + break; + } + php_info_print_table_row(2, "log_level", buf); + + FPM_INFO_ROW_INT(emergency_restart_threshold); + FPM_INFO_ROW_INT(emergency_restart_interval); + FPM_INFO_ROW_INT(process_control_timeout); + FPM_INFO_ROW_INT(process_max); + FPM_INFO_ROW_INT(process_priority); + FPM_INFO_ROW_INT(daemonize); + FPM_INFO_ROW_INT(rlimit_files); + FPM_INFO_ROW_INT(rlimit_core); + + php_info_print_table_row(2, "events_mechanism", fpm_global_config.events_mechanism); + +#ifdef HAVE_SYSTEMD + FPM_INFO_ROW_INT(systemd_watchdog); + FPM_INFO_ROW_INT(systemd_interval); +#endif + php_info_print_table_end(); + if (this_child && this_child->wp && this_child->wp->config) { + php_info_print_table_start(); + php_info_print_table_header(2, "PHP-FPM current pool configuration", "Value"); + FPM_POOL_INFO_STR(name); + FPM_POOL_INFO_STR(prefix); + FPM_POOL_INFO_STR(user); + FPM_POOL_INFO_STR(group); + FPM_POOL_INFO_STR(listen_address); + FPM_POOL_INFO_INT(listen_backlog); + FPM_POOL_INFO_STR(listen_owner); + FPM_POOL_INFO_STR(listen_group); + FPM_POOL_INFO_STR(listen_mode); + FPM_POOL_INFO_STR(listen_allowed_clients); + FPM_POOL_INFO_INT(process_priority); + switch (this_child->wp->config->pm) { + case PM_STYLE_STATIC: + sprintf(buf, "static"); + break; + case PM_STYLE_DYNAMIC: + sprintf(buf, "dynamic"); + break; + case PM_STYLE_ONDEMAND: + sprintf(buf, "ondemand"); + break; + default: + sprintf(buf, "invalid pm value (%d)", this_child->wp->config->pm); + break; + } + php_info_print_table_row(2, "pm", buf); + + FPM_POOL_INFO_INT(pm_max_children); + FPM_POOL_INFO_INT(pm_start_servers); + FPM_POOL_INFO_INT(pm_min_spare_servers); + FPM_POOL_INFO_INT(pm_max_spare_servers); + FPM_POOL_INFO_INT(pm_process_idle_timeout); + FPM_POOL_INFO_INT(pm_max_requests); + FPM_POOL_INFO_STR(pm_status_path); + FPM_POOL_INFO_STR(ping_path); + FPM_POOL_INFO_STR(ping_response); + FPM_POOL_INFO_STR(access_log); + FPM_POOL_INFO_STR(access_format); + FPM_POOL_INFO_STR(slowlog); + FPM_POOL_INFO_INT(request_slowlog_timeout); + FPM_POOL_INFO_INT(request_terminate_timeout); + FPM_POOL_INFO_INT(rlimit_files); + FPM_POOL_INFO_INT(rlimit_core); + FPM_POOL_INFO_STR(chroot); + FPM_POOL_INFO_STR(chdir); + FPM_POOL_INFO_INT(catch_workers_output); + FPM_POOL_INFO_STR(security_limit_extensions); + + php_info_print_table_end(); + } + DISPLAY_INI_ENTRIES(); } /* }}} */ @@ -1524,8 +1642,143 @@ PHP_FUNCTION(fastcgi_finish_request) /* {{{ */ } /* }}} */ +#define FPM_GET_INT(name) \ + add_assoc_long(return_value, #name, fpm_global_config.name) + +#define FPM_GET_STR(name) \ + if (fpm_global_config.name) { \ + add_assoc_string(return_value, #name, fpm_global_config.name, 1); \ + } else { \ + add_assoc_string(return_value, #name, "", 1); \ + } \ + +#define FPM_GET_POOL_INT(name) \ + add_assoc_long(pool, #name, this_child->wp->config->name) + +#define FPM_GET_POOL_STR(name) \ + if (this_child->wp->config->name) { \ + add_assoc_string(pool, #name, this_child->wp->config->name, 1); \ + } else { \ + add_assoc_string(pool, #name, "", 1); \ + } + + +PHP_FUNCTION(fpm_get_configuration) /* {{{ */ +{ + zval *pool; + + if (!this_child || !this_child->wp || !this_child->wp->config) { + RETURN_FALSE; + } + + array_init(return_value); + + FPM_GET_STR(pid_file); + FPM_GET_STR(error_log); + +#ifdef HAVE_SYSLOG_H + FPM_GET_STR(syslog_ident); + + FPM_GET_INT(syslog_facility); +#endif + + switch (fpm_global_config.log_level) { + case ZLOG_DEBUG: + add_assoc_string(return_value, "log_level", "debug", 1); + break; + case ZLOG_NOTICE: + add_assoc_string(return_value, "log_level", "notice", 1); + break; + case ZLOG_WARNING: + add_assoc_string(return_value, "log_level", "warning", 1); + break; + case ZLOG_ERROR: + add_assoc_string(return_value, "log_level", "error", 1); + break; + case ZLOG_ALERT: + add_assoc_string(return_value, "log_level", "alert", 1); + break; + default: + add_assoc_string(return_value, "log_level", "unknown", 1); + break; + } + + FPM_GET_INT(emergency_restart_threshold); + FPM_GET_INT(emergency_restart_interval); + FPM_GET_INT(process_control_timeout); + FPM_GET_INT(process_max); + FPM_GET_INT(process_priority); + FPM_GET_INT(daemonize); + FPM_GET_INT(rlimit_files); + FPM_GET_INT(rlimit_core); + + FPM_GET_STR(events_mechanism); + +#ifdef HAVE_SYSTEMD + FPM_GET_INT(systemd_watchdog); + FPM_GET_INT(systemd_interval); +#endif + + MAKE_STD_ZVAL(pool); + array_init(pool); + + add_assoc_zval(return_value, "pool", pool); + + if (this_child && this_child->wp && this_child->wp->config) { + FPM_GET_POOL_STR(name); + FPM_GET_POOL_STR(prefix); + FPM_GET_POOL_STR(user); + FPM_GET_POOL_STR(group); + FPM_GET_POOL_STR(listen_address); + FPM_GET_POOL_INT(listen_backlog); + FPM_GET_POOL_STR(listen_owner); + FPM_GET_POOL_STR(listen_group); + FPM_GET_POOL_STR(listen_mode); + FPM_GET_POOL_STR(listen_allowed_clients); + FPM_GET_POOL_INT(process_priority); + + switch (this_child->wp->config->pm) { + case PM_STYLE_STATIC: + add_assoc_string(pool, "pm", "static", 1); + break; + case PM_STYLE_DYNAMIC: + add_assoc_string(pool, "pm", "dynamic", 1); + break; + case PM_STYLE_ONDEMAND: + add_assoc_string(pool, "pm", "ondemand", 1); + break; + default: + add_assoc_string(pool, "pm", "unknown", 1); + break; + } + + FPM_GET_POOL_INT(pm_max_children); + FPM_GET_POOL_INT(pm_start_servers); + FPM_GET_POOL_INT(pm_min_spare_servers); + FPM_GET_POOL_INT(pm_max_spare_servers); + FPM_GET_POOL_INT(pm_process_idle_timeout); + FPM_GET_POOL_INT(pm_max_requests); + FPM_GET_POOL_STR(pm_status_path); + FPM_GET_POOL_STR(ping_path); + FPM_GET_POOL_STR(ping_response); + FPM_GET_POOL_STR(access_log); + FPM_GET_POOL_STR(access_format); + FPM_GET_POOL_STR(slowlog); + FPM_GET_POOL_INT(request_slowlog_timeout); + FPM_GET_POOL_INT(request_terminate_timeout); + FPM_GET_POOL_INT(rlimit_files); + FPM_GET_POOL_INT(rlimit_core); + FPM_GET_POOL_STR(chroot); + FPM_GET_POOL_STR(chdir); + FPM_GET_POOL_INT(catch_workers_output); + FPM_GET_POOL_STR(security_limit_extensions); + } +} +/* }}} */ + static const zend_function_entry cgi_fcgi_sapi_functions[] = { PHP_FE(fastcgi_finish_request, NULL) + PHP_FE(fpm_get_configuration, NULL) {NULL, NULL, NULL} }; @@ -1967,6 +2220,8 @@ fastcgi_request_done: } /* end of fastcgi loop */ } + fpm_cleanups_run(FPM_CLEANUP_CHILD); + fpm_child_free(this_child); fcgi_shutdown(); if (cgi_sapi_module.php_ini_path_override) { @@ -1982,8 +2237,8 @@ fastcgi_request_done: out: SG(server_context) = NULL; + php_module_shutdown(TSRMLS_C); if (parent) { - php_module_shutdown(TSRMLS_C); sapi_shutdown(); }
diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index b866f37..4d3252a 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -114,8 +114,6 @@ int fpm_run(int *max_requests) /* {{{ */ run_child: /* only workers reach this point */ - fpm_cleanups_run(FPM_CLEANUP_CHILD); - *max_requests = fpm_globals.max_requests; return fpm_globals.listening_socket; } diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index 45cc075..c063820 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -34,6 +34,8 @@ static time_t *last_faults; static int fault; +struct fpm_child_s *this_child = NULL; + static void fpm_children_cleanup(int which, void *arg) /* {{{ */ { free(last_faults); @@ -56,7 +58,7 @@ static struct fpm_child_s *fpm_child_alloc() /* {{{ */ } /* }}} */ -static void fpm_child_free(struct fpm_child_s *child) /* {{{ */ +void fpm_child_free(struct fpm_child_s *child) /* {{{ */ { free(child); } @@ -347,7 +349,6 @@ static void fpm_child_resources_use(struct fpm_child_s *child) /* {{{ */ fpm_scoreboard_child_use(child->wp->scoreboard, child->scoreboard_i, getpid()); fpm_stdio_child_use_pipes(child); - fpm_child_free(child); } /* }}} */ @@ -404,6 +405,7 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to case 0 : fpm_child_resources_use(child); fpm_globals.is_child = 1; + this_child = child; fpm_child_init(wp); return 0; diff --git a/sapi/fpm/fpm/fpm_children.h b/sapi/fpm/fpm/fpm_children.h index 9c79f23..f43112d 100644 --- a/sapi/fpm/fpm/fpm_children.h +++ b/sapi/fpm/fpm/fpm_children.h @@ -16,6 +16,9 @@ int fpm_children_free(struct fpm_child_s *child); void fpm_children_bury(); int fpm_children_init_main(); int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug); +void fpm_child_free(struct fpm_child_s *child); + +extern struct fpm_child_s *this_child; struct fpm_child_s; diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 043e0e0..c405449 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -104,8 +104,10 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include "fpm_request.h" #include "fpm_status.h" #include "fpm_conf.h" +#include "fpm_children.h" #include "fpm_php.h" #include "fpm_log.h" +#include "fpm_cleanup.h" #include "zlog.h" #ifndef PHP_WIN32 @@ -1493,14 +1495,130 @@ static PHP_MSHUTDOWN_FUNCTION(cgi) } /* }}} */ +#define FPM_INFO_ROW_INT(name) \ + sprintf(buf, "%d", fpm_global_config.name); \ + php_info_print_table_row(2, #name, buf); + +#define FPM_POOL_INFO_STR(name) \ + php_info_print_table_row(2, #name, this_child->wp->config->name); + +#define FPM_POOL_INFO_INT(name) \ + sprintf(buf, "%d", this_child->wp->config->name); \ + php_info_print_table_row(2, #name, buf); + /* {{{ PHP_MINFO_FUNCTION */ static PHP_MINFO_FUNCTION(cgi) { + char buf[256]; + php_info_print_table_start(); + php_info_print_table_header(2, "PHP-FPM global configuration", "Value"); php_info_print_table_row(2, "php-fpm", "active"); + php_info_print_table_row(2, "pid_file", fpm_global_config.pid_file); + php_info_print_table_row(2, "error_log", fpm_global_config.error_log); + +#ifdef HAVE_SYSLOG_H + php_info_print_table_row(2, "syslog_ident", fpm_global_config.syslog_ident); + + sprintf(buf, "%d", fpm_global_config.syslog_facility); + php_info_print_table_row(2, "syslog_facility", buf); +#endif + + switch (fpm_global_config.log_level) { + case ZLOG_DEBUG: + sprintf(buf, "debug"); + break; + case ZLOG_NOTICE: + sprintf(buf, "notice"); + break; + case ZLOG_WARNING: + sprintf(buf, "warning"); + break; + case ZLOG_ERROR: + sprintf(buf, "error"); + break; + case ZLOG_ALERT: + sprintf(buf, "alert"); + break; + default: + sprintf(buf, "unknown log_level value (%d)", fpm_global_config.log_level); + break; + } + php_info_print_table_row(2, "log_level", buf); + + FPM_INFO_ROW_INT(emergency_restart_threshold); + FPM_INFO_ROW_INT(emergency_restart_interval); + FPM_INFO_ROW_INT(process_control_timeout); + FPM_INFO_ROW_INT(process_max); + FPM_INFO_ROW_INT(process_priority); + FPM_INFO_ROW_INT(daemonize); + FPM_INFO_ROW_INT(rlimit_files); + FPM_INFO_ROW_INT(rlimit_core); + + php_info_print_table_row(2, "events_mechanism", fpm_global_config.events_mechanism); + +#ifdef HAVE_SYSTEMD + FPM_INFO_ROW_INT(systemd_watchdog); + FPM_INFO_ROW_INT(systemd_interval); +#endif + php_info_print_table_end(); + if (this_child && this_child->wp && this_child->wp->config) { + php_info_print_table_start(); + php_info_print_table_header(2, "PHP-FPM current pool configuration", "Value"); + FPM_POOL_INFO_STR(name); + FPM_POOL_INFO_STR(prefix); + FPM_POOL_INFO_STR(user); + FPM_POOL_INFO_STR(group); + FPM_POOL_INFO_STR(listen_address); + FPM_POOL_INFO_INT(listen_backlog); + FPM_POOL_INFO_STR(listen_owner); + FPM_POOL_INFO_STR(listen_group); + FPM_POOL_INFO_STR(listen_mode); + FPM_POOL_INFO_STR(listen_allowed_clients); + FPM_POOL_INFO_INT(process_priority); + switch (this_child->wp->config->pm) { + case PM_STYLE_STATIC: + sprintf(buf, "static"); + break; + case PM_STYLE_DYNAMIC: + sprintf(buf, "dynamic"); + break; + case PM_STYLE_ONDEMAND: + sprintf(buf, "ondemand"); + break; + default: + sprintf(buf, "invalid pm value (%d)", this_child->wp->config->pm); + break; + } + php_info_print_table_row(2, "pm", buf); + + FPM_POOL_INFO_INT(pm_max_children); + FPM_POOL_INFO_INT(pm_start_servers); + FPM_POOL_INFO_INT(pm_min_spare_servers); + FPM_POOL_INFO_INT(pm_max_spare_servers); + FPM_POOL_INFO_INT(pm_process_idle_timeout); + FPM_POOL_INFO_INT(pm_max_requests); + FPM_POOL_INFO_STR(pm_status_path); + FPM_POOL_INFO_STR(ping_path); + FPM_POOL_INFO_STR(ping_response); + FPM_POOL_INFO_STR(access_log); + FPM_POOL_INFO_STR(access_format); + FPM_POOL_INFO_STR(slowlog); + FPM_POOL_INFO_INT(request_slowlog_timeout); + FPM_POOL_INFO_INT(request_terminate_timeout); + FPM_POOL_INFO_INT(rlimit_files); + FPM_POOL_INFO_INT(rlimit_core); + FPM_POOL_INFO_STR(chroot); + FPM_POOL_INFO_STR(chdir); + FPM_POOL_INFO_INT(catch_workers_output); + FPM_POOL_INFO_STR(security_limit_extensions); + + php_info_print_table_end(); + } + DISPLAY_INI_ENTRIES(); } /* }}} */ @@ -1524,8 +1642,143 @@ PHP_FUNCTION(fastcgi_finish_request) /* {{{ */ } /* }}} */ +#define FPM_GET_INT(name) \ + add_assoc_long(return_value, #name, fpm_global_config.name) + +#define FPM_GET_STR(name) \ + if (fpm_global_config.name) { \ + add_assoc_string(return_value, #name, fpm_global_config.name, 1); \ + } else { \ + add_assoc_string(return_value, #name, "", 1); \ + } \ + +#define FPM_GET_POOL_INT(name) \ + add_assoc_long(pool, #name, this_child->wp->config->name) + +#define FPM_GET_POOL_STR(name) \ + if (this_child->wp->config->name) { \ + add_assoc_string(pool, #name, this_child->wp->config->name, 1); \ + } else { \ + add_assoc_string(pool, #name, "", 1); \ + } + + +PHP_FUNCTION(fpm_get_configuration) /* {{{ */ +{ + zval *pool; + + if (!this_child || !this_child->wp || !this_child->wp->config) { + RETURN_FALSE; + } + + array_init(return_value); + + FPM_GET_STR(pid_file); + FPM_GET_STR(error_log); + +#ifdef HAVE_SYSLOG_H + FPM_GET_STR(syslog_ident); + + FPM_GET_INT(syslog_facility); +#endif + + switch (fpm_global_config.log_level) { + case ZLOG_DEBUG: + add_assoc_string(return_value, "log_level", "debug", 1); + break; + case ZLOG_NOTICE: + add_assoc_string(return_value, "log_level", "notice", 1); + break; + case ZLOG_WARNING: + add_assoc_string(return_value, "log_level", "warning", 1); + break; + case ZLOG_ERROR: + add_assoc_string(return_value, "log_level", "error", 1); + break; + case ZLOG_ALERT: + add_assoc_string(return_value, "log_level", "alert", 1); + break; + default: + add_assoc_string(return_value, "log_level", "unknown", 1); + break; + } + + FPM_GET_INT(emergency_restart_threshold); + FPM_GET_INT(emergency_restart_interval); + FPM_GET_INT(process_control_timeout); + FPM_GET_INT(process_max); + FPM_GET_INT(process_priority); + FPM_GET_INT(daemonize); + FPM_GET_INT(rlimit_files); + FPM_GET_INT(rlimit_core); + + FPM_GET_STR(events_mechanism); + +#ifdef HAVE_SYSTEMD + FPM_GET_INT(systemd_watchdog); + FPM_GET_INT(systemd_interval); +#endif + + MAKE_STD_ZVAL(pool); + array_init(pool); + + add_assoc_zval(return_value, "pool", pool); + + if (this_child && this_child->wp && this_child->wp->config) { + FPM_GET_POOL_STR(name); + FPM_GET_POOL_STR(prefix); + FPM_GET_POOL_STR(user); + FPM_GET_POOL_STR(group); + FPM_GET_POOL_STR(listen_address); + FPM_GET_POOL_INT(listen_backlog); + FPM_GET_POOL_STR(listen_owner); + FPM_GET_POOL_STR(listen_group); + FPM_GET_POOL_STR(listen_mode); + FPM_GET_POOL_STR(listen_allowed_clients); + FPM_GET_POOL_INT(process_priority); + + switch (this_child->wp->config->pm) { + case PM_STYLE_STATIC: + add_assoc_string(pool, "pm", "static", 1); + break; + case PM_STYLE_DYNAMIC: + add_assoc_string(pool, "pm", "dynamic", 1); + break; + case PM_STYLE_ONDEMAND: + add_assoc_string(pool, "pm", "ondemand", 1); + break; + default: + add_assoc_string(pool, "pm", "unknown", 1); + break; + } + + FPM_GET_POOL_INT(pm_max_children); + FPM_GET_POOL_INT(pm_start_servers); + FPM_GET_POOL_INT(pm_min_spare_servers); + FPM_GET_POOL_INT(pm_max_spare_servers); + FPM_GET_POOL_INT(pm_process_idle_timeout); + FPM_GET_POOL_INT(pm_max_requests); + FPM_GET_POOL_STR(pm_status_path); + FPM_GET_POOL_STR(ping_path); + FPM_GET_POOL_STR(ping_response); + FPM_GET_POOL_STR(access_log); + FPM_GET_POOL_STR(access_format); + FPM_GET_POOL_STR(slowlog); + FPM_GET_POOL_INT(request_slowlog_timeout); + FPM_GET_POOL_INT(request_terminate_timeout); + FPM_GET_POOL_INT(rlimit_files); + FPM_GET_POOL_INT(rlimit_core); + FPM_GET_POOL_STR(chroot); + FPM_GET_POOL_STR(chdir); + FPM_GET_POOL_INT(catch_workers_output); + FPM_GET_POOL_STR(security_limit_extensions); + } +} +/* }}} */ + static const zend_function_entry cgi_fcgi_sapi_functions[] = { PHP_FE(fastcgi_finish_request, NULL) + PHP_FE(fpm_get_configuration, NULL) {NULL, NULL, NULL} }; @@ -1967,6 +2220,8 @@ fastcgi_request_done: } /* end of fastcgi loop */ } + fpm_cleanups_run(FPM_CLEANUP_CHILD); + fpm_child_free(this_child); fcgi_shutdown(); if (cgi_sapi_module.php_ini_path_override) { @@ -1982,8 +2237,8 @@ fastcgi_request_done: out: SG(server_context) = NULL; + php_module_shutdown(TSRMLS_C); if (parent) { - php_module_shutdown(TSRMLS_C); sapi_shutdown(); }