diff options
Diffstat (limited to 'sapi')
186 files changed, 3632 insertions, 1945 deletions
diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c index 05c9e85828..4c9c80f942 100644 --- a/sapi/apache2handler/apache_config.c +++ b/sapi/apache2handler/apache_config.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index 8879140843..44dee3fad5 100644 --- a/sapi/apache2handler/config.m4 +++ b/sapi/apache2handler/config.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi apache2handler PHP_ARG_WITH(apxs2,, [ --with-apxs2[=FILE] Build shared Apache 2.0 Handler module. FILE is the optional @@ -103,13 +101,6 @@ if test "$PHP_APXS2" != "no"; then SAPI_SHARED=libs/libphp7.so INSTALL_IT="$INSTALL_IT $SAPI_SHARED" ;; - *beos*) - if test -f _APP_; then `rm _APP_`; fi - `ln -s $APXS_BINDIR/httpd _APP_` - EXTRA_LIBS="$EXTRA_LIBS _APP_" - PHP_SELECT_SAPI(apache2handler, shared, mod_php7.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS) - INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL" - ;; *) PHP_SELECT_SAPI(apache2handler, shared, mod_php7.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS) INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL" diff --git a/sapi/apache2handler/config.w32 b/sapi/apache2handler/config.w32 index 20a801ff9e..45d6353d28 100644 --- a/sapi/apache2handler/config.w32 +++ b/sapi/apache2handler/config.w32 @@ -1,5 +1,4 @@ // vim:ft=javascript -// $Id$ ARG_ENABLE('apache2handler', 'Build Apache 2.x handler', 'no'); diff --git a/sapi/apache2handler/mod_php7.c b/sapi/apache2handler/mod_php7.c index 3f0e7d5da9..e2f96592cc 100644 --- a/sapi/apache2handler/mod_php7.c +++ b/sapi/apache2handler/mod_php7.c @@ -18,8 +18,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h index c93e20c90f..ae5e5972cc 100644 --- a/sapi/apache2handler/php_apache.h +++ b/sapi/apache2handler/php_apache.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef PHP_APACHE_H #define PHP_APACHE_H diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index 572aa98b2f..6638fddda1 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" @@ -42,7 +40,7 @@ #include "util_script.h" #include "http_core.h" #include "ap_mpm.h" -#if !defined(WIN32) && !defined(WINNT) +#ifndef PHP_WIN32 #include "unixd.h" #endif @@ -371,12 +369,12 @@ PHP_MINFO_FUNCTION(apache) int n, max_requests; char *p; server_rec *serv = ((php_struct *) SG(server_context))->r->server; -#if !defined(WIN32) && !defined(WINNT) -#if MODULE_MAGIC_NUMBER_MAJOR >= 20081201 +#ifndef PHP_WIN32 +# if MODULE_MAGIC_NUMBER_MAJOR >= 20081201 AP_DECLARE_DATA extern unixd_config_rec ap_unixd_config; -#else +# else AP_DECLARE_DATA extern unixd_config_rec unixd_config; -#endif +# endif #endif for (n = 0; ap_loaded_modules[n]; ++n) { @@ -410,7 +408,7 @@ PHP_MINFO_FUNCTION(apache) snprintf(tmp, sizeof(tmp), "%s:%u", serv->server_hostname, serv->port); php_info_print_table_row(2, "Hostname:Port", tmp); -#if !defined(WIN32) && !defined(WINNT) +#ifndef PHP_WIN32 #if MODULE_MAGIC_NUMBER_MAJOR >= 20081201 snprintf(tmp, sizeof(tmp), "%s(%d)/%d", ap_unixd_config.user_name, ap_unixd_config.user_id, ap_unixd_config.group_id); #else diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 2813ae363c..23eef816a8 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -18,8 +18,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h" diff --git a/sapi/cgi/CHANGES b/sapi/cgi/CHANGES deleted file mode 100755 index b7cf41cf5e..0000000000 --- a/sapi/cgi/CHANGES +++ /dev/null @@ -1,33 +0,0 @@ -In PHP5.3 all additional configure options (except --enable-cgi) are removed: - - --enable-fastcgi CGI: If this is enabled, the cgi module will - be built with support for fastcgi also - - Now fastcgi is always enabled - - --disable-path-info-check CGI: If this is disabled, paths such as - /info.php/test?a=b will fail to work - - Now it is enabled by default, but can be disabled - with ini directive "cgi.fix_pathinfo=0" - - --enable-force-cgi-redirect - CGI: Enable the security check for internal server - redirects. You should use this if you are - running the CGI version with Apache - - Now it is enabled by default, but can be disabled - with ini directive "cgi.force_redirect=0" - - --enable-discard-path CGI: If this is enabled, the PHP CGI binary - can safely be placed outside of the - web tree and people will not be able - to circumvent .htaccess security - - This option had effect only with - --disable-path-info-check or "cgi.fix_pathinfo=0". - Seems it needs only for CGI configuration that - require each script start from "#! /usr/bin/php". - - Now it is disabled by default, but can be enabled - with ini directive "cgi.discard_path=1". diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 16bb2126d2..fb16f2b577 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -14,15 +14,13 @@ +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | | Stig Bakken <ssb@php.net> | - | Zeev Suraski <zeev@zend.com> | + | Zeev Suraski <zeev@php.net> | | FastCGI: Ben Mansell <php@slimyhorror.com> | | Shane Caraveo <shane@caraveo.com> | - | Dmitry Stogov <dmitry@zend.com> | + | Dmitry Stogov <dmitry@php.net> | +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -380,7 +378,6 @@ static void sapi_fcgi_flush(void *server_context) static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers) { - char buf[SAPI_CGI_MAX_HEADER_LENGTH]; sapi_header_struct *h; zend_llist_position pos; zend_bool ignore_status = 0; @@ -394,6 +391,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers) { int len; zend_bool has_status = 0; + char buf[SAPI_CGI_MAX_HEADER_LENGTH]; if (CGIG(rfc2616_headers) && SG(sapi_headers).http_status_line) { char *s; @@ -675,20 +673,17 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns static void cgi_php_import_environment_variables(zval *array_ptr) { - if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && - Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) && - zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0 - ) { - zval_dtor(array_ptr); - ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]); - return; - } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && - Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) && - zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0 - ) { - zval_dtor(array_ptr); - ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]); - return; + if (PG(variables_order) && (strchr(PG(variables_order),'E') || strchr(PG(variables_order),'e'))) { + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) { + zend_is_auto_global_str("_ENV", sizeof("_ENV")-1); + } + + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) { + zend_array_destroy(Z_ARR_P(array_ptr)); + Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_ENV])); + return; + } } /* call php's original import as a catch-all */ @@ -796,7 +791,6 @@ static void sapi_cgi_log_message(char *message, int syslog_type_int) */ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const char *doc_root, size_t doc_root_len, int start) { - char *ptr; user_config_cache_entry *new_entry, *entry; time_t request_time = (time_t)sapi_get_request_time(); @@ -812,7 +806,6 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const /* Check whether cache entry has expired and rescan if it is */ if (request_time > entry->expires) { char *real_path = NULL; - size_t real_path_len; char *s1, *s2; size_t s_len; @@ -820,6 +813,7 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const zend_hash_clean(entry->user_config); if (!IS_ABSOLUTE_PATH(path, path_len)) { + size_t real_path_len; real_path = tsrm_realpath(path, NULL); if (real_path == NULL) { return; @@ -848,7 +842,7 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const #else if (strncmp(s1, s2, s_len) == 0) { #endif - ptr = s2 + start; /* start is the point where doc_root ends! */ + char *ptr = s2 + start; /* start is the point where doc_root ends! */ while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { *ptr = 0; php_parse_user_ini_file(path, PG(user_ini_filename), entry->user_config); @@ -872,15 +866,14 @@ static void php_cgi_ini_activate_user_config(char *path, size_t path_len, const static int sapi_cgi_activate(void) { - char *path, *doc_root, *server_name; - size_t path_len, doc_root_len, server_name_len; - /* PATH_TRANSLATED should be defined at this stage but better safe than sorry :) */ if (!SG(request_info).path_translated) { return FAILURE; } if (php_ini_has_per_host_config()) { + char *server_name; + /* Activate per-host-system-configuration defined in php.ini and stored into configuration_hash during startup */ if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); @@ -891,7 +884,7 @@ static int sapi_cgi_activate(void) } /* SERVER_NAME should also be defined at this stage..but better check it anyway */ if (server_name) { - server_name_len = strlen(server_name); + size_t server_name_len = strlen(server_name); server_name = estrndup(server_name, server_name_len); zend_str_tolower(server_name, server_name_len); php_ini_activate_per_host_config(server_name, server_name_len); @@ -902,6 +895,9 @@ static int sapi_cgi_activate(void) if (php_ini_has_per_dir_config() || (PG(user_ini_filename) && *PG(user_ini_filename)) ) { + char *path; + size_t path_len; + /* Prepare search path */ path_len = strlen(SG(request_info).path_translated); @@ -922,6 +918,8 @@ static int sapi_cgi_activate(void) /* Load and activate user ini files in path starting from DOCUMENT_ROOT */ if (PG(user_ini_filename) && *PG(user_ini_filename)) { + char *doc_root; + if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); @@ -931,7 +929,7 @@ static int sapi_cgi_activate(void) } /* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */ if (doc_root) { - doc_root_len = strlen(doc_root); + size_t doc_root_len = strlen(doc_root); if (doc_root_len > 0 && IS_SLASH(doc_root[doc_root_len - 1])) { --doc_root_len; } @@ -1202,7 +1200,7 @@ static void init_request_info(fcgi_request *request) /* script_path_translated being set is a good indication that * we are running in a cgi environment, since it is always * null otherwise. otherwise, the filename - * of the script will be retreived later via argc/argv */ + * of the script will be retrieved later via argc/argv */ if (script_path_translated) { const char *auth; char *content_length = CGI_GETENV("CONTENT_LENGTH"); @@ -1369,9 +1367,8 @@ static void init_request_info(fcgi_request *request) /* PATH_TRANSLATED = PATH_TRANSLATED - SCRIPT_NAME + PATH_INFO */ size_t ptlen = strlen(pt) - strlen(env_script_name); size_t path_translated_len = ptlen + (env_path_info ? strlen(env_path_info) : 0); - char *path_translated = NULL; - path_translated = (char *) emalloc(path_translated_len + 1); + char *path_translated = (char *) emalloc(path_translated_len + 1); memcpy(path_translated, pt, ptlen); if (env_path_info) { memcpy(path_translated + ptlen, env_path_info, path_translated_len - ptlen); @@ -1596,53 +1593,6 @@ PHP_FUNCTION(apache_child_terminate) /* {{{ */ } /* }}} */ -static void add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */ -{ - zval *return_value = (zval*)arg; - char *str = NULL; - char *p; - ALLOCA_FLAG(use_heap) - - if (var_len > 5 && - var[0] == 'H' && - var[1] == 'T' && - var[2] == 'T' && - var[3] == 'P' && - var[4] == '_') { - - var_len -= 5; - p = var + 5; - var = str = do_alloca(var_len + 1, use_heap); - *str++ = *p++; - while (*p) { - if (*p == '_') { - *str++ = '-'; - p++; - if (*p) { - *str++ = *p++; - } - } else if (*p >= 'A' && *p <= 'Z') { - *str++ = (*p++ - 'A' + 'a'); - } else { - *str++ = *p++; - } - } - *str = 0; - } else if (var_len == sizeof("CONTENT_TYPE")-1 && - memcmp(var, "CONTENT_TYPE", sizeof("CONTENT_TYPE")-1) == 0) { - var = "Content-Type"; - } else if (var_len == sizeof("CONTENT_LENGTH")-1 && - memcmp(var, "CONTENT_LENGTH", sizeof("CONTENT_LENGTH")-1) == 0) { - var = "Content-Length"; - } else { - return; - } - add_assoc_stringl_ex(return_value, var, var_len, val, val_len); - if (str) { - free_alloca(var, use_heap); - } -} -/* }}} */ PHP_FUNCTION(apache_request_headers) /* {{{ */ { @@ -1653,7 +1603,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */ if (fcgi_is_fastcgi()) { fcgi_request *request = (fcgi_request*) SG(server_context); - fcgi_loadenv(request, add_request_header, return_value); + fcgi_loadenv(request, sapi_add_request_header, return_value); } else { char buf[128]; char **env, *p, *q, *var, *val, *t = buf; @@ -1729,12 +1679,12 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */ static void add_response_header(sapi_header_struct *h, zval *return_value) /* {{{ */ { - char *s, *p; - size_t len = 0; - ALLOCA_FLAG(use_heap) - if (h->header_len > 0) { - p = strchr(h->header, ':'); + char *s; + size_t len = 0; + ALLOCA_FLAG(use_heap) + + char *p = strchr(h->header, ':'); if (NULL != p) { len = p - h->header; } @@ -1771,7 +1721,7 @@ PHP_FUNCTION(apache_response_headers) /* {{{ */ ZEND_BEGIN_ARG_INFO(arginfo_no_args, 0) ZEND_END_ARG_INFO() -const zend_function_entry cgi_functions[] = { +static const zend_function_entry cgi_functions[] = { PHP_FE(apache_child_terminate, arginfo_no_args) PHP_FE(apache_request_headers, arginfo_no_args) PHP_FE(apache_response_headers, arginfo_no_args) @@ -2038,6 +1988,11 @@ consult the installation file that came with this distribution, or visit \n\ } fastcgi = fcgi_is_fastcgi(); } + + /* make php call us to get _ENV vars */ + php_php_import_environment_variables = php_import_environment_variables; + php_import_environment_variables = cgi_php_import_environment_variables; + if (fastcgi) { /* How many times to run PHP scripts before dying */ if (getenv("PHP_FCGI_MAX_REQUESTS")) { @@ -2048,10 +2003,6 @@ consult the installation file that came with this distribution, or visit \n\ } } - /* make php call us to get _ENV vars */ - php_php_import_environment_variables = php_import_environment_variables; - php_import_environment_variables = cgi_php_import_environment_variables; - /* library is already initialized, now init our request */ request = fcgi_init_request(fcgi_fd, NULL, NULL, NULL); @@ -2437,10 +2388,8 @@ parent_loop_end: php_module_shutdown(); return FAILURE; } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } + SG(headers_sent) = 1; + SG(request_info).no_headers = 1; #if ZEND_DEBUG php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else diff --git a/sapi/cgi/config.w32 b/sapi/cgi/config.w32 index 4e803fb1c4..5f7b040b63 100644 --- a/sapi/cgi/config.w32 +++ b/sapi/cgi/config.w32 @@ -1,5 +1,4 @@ // vim:ft=javascript -// $Id$ ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes'); diff --git a/sapi/cgi/config9.m4 b/sapi/cgi/config9.m4 index 1935864be3..bdf9edbdc1 100644 --- a/sapi/cgi/config9.m4 +++ b/sapi/cgi/config9.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi cgi PHP_ARG_ENABLE(cgi,, [ --disable-cgi Disable building CGI version of PHP], yes, no) diff --git a/sapi/cgi/tests/005-win32.phpt b/sapi/cgi/tests/005-win32.phpt index 65ab5a45b3..1674f16fb9 100644 --- a/sapi/cgi/tests/005-win32.phpt +++ b/sapi/cgi/tests/005-win32.phpt @@ -22,7 +22,7 @@ var_dump(`$php -n -f "wrong" -a`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(51) "Interactive mode enabled No input file specified. diff --git a/sapi/cgi/tests/005.phpt b/sapi/cgi/tests/005.phpt index 8b6254c089..6b41f7a99f 100644 --- a/sapi/cgi/tests/005.phpt +++ b/sapi/cgi/tests/005.phpt @@ -22,7 +22,7 @@ var_dump(`$php -n -f 'wrong' -a`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(51) "No input file specified. Interactive mode enabled diff --git a/sapi/cgi/tests/007.phpt b/sapi/cgi/tests/007.phpt index 28cf1db1f4..950f451083 100644 --- a/sapi/cgi/tests/007.phpt +++ b/sapi/cgi/tests/007.phpt @@ -14,7 +14,7 @@ var_dump(`"$php" -n -s -w -l`); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- string(25) "No input file specified. " string(49) "No syntax errors detected in Standard input code diff --git a/sapi/cgi/tests/bug75574_utf8_win.phpt b/sapi/cgi/tests/bug75574_utf8_win.phpt index 8f9c70e089..c6e33e54ed 100644 --- a/sapi/cgi/tests/bug75574_utf8_win.phpt +++ b/sapi/cgi/tests/bug75574_utf8_win.phpt @@ -29,7 +29,7 @@ unlink($fn); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- bool(true) string(3) "啊" ===DONE=== diff --git a/sapi/cli/TODO b/sapi/cli/TODO deleted file mode 100644 index 22e6689001..0000000000 --- a/sapi/cli/TODO +++ /dev/null @@ -1,2 +0,0 @@ -TODO: - diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h index 0a76895c58..5cc39ff00b 100644 --- a/sapi/cli/cli.h +++ b/sapi/cli/cli.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef CLI_H #define CLI_H @@ -30,7 +28,7 @@ #endif -extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length); +extern PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length); typedef struct { size_t (*cli_shell_write)(const char *str, size_t str_length); diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4 index 21681512a7..93c9e7b702 100644 --- a/sapi/cli/config.m4 +++ b/sapi/cli/config.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi cli PHP_ARG_ENABLE(cli,, [ --disable-cli Disable building CLI version of PHP @@ -11,12 +9,11 @@ AC_CHECK_FUNCS(setproctitle) AC_CHECK_HEADERS([sys/pstat.h]) AC_CACHE_CHECK([for PS_STRINGS], [cli_cv_var_PS_STRINGS], -[AC_TRY_LINK( -[#include <machine/vmparam.h> +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <machine/vmparam.h> #include <sys/exec.h> -], -[PS_STRINGS->ps_nargvstr = 1; -PS_STRINGS->ps_argvstr = "foo";], +]], +[[PS_STRINGS->ps_nargvstr = 1; +PS_STRINGS->ps_argvstr = "foo";]])], [cli_cv_var_PS_STRINGS=yes], [cli_cv_var_PS_STRINGS=no])]) if test "$cli_cv_var_PS_STRINGS" = yes ; then diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index 2b54f7dee1..26c53f7808 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -1,5 +1,4 @@ // vim:ft=javascript -// $Id$ ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes'); ARG_ENABLE('crt-debug', 'Enable CRT memory dumps for debugging sent to STDERR', 'no'); diff --git a/sapi/cli/generate_mime_type_map.php b/sapi/cli/generate_mime_type_map.php index 13ae59dc0c..0cea031e37 100644 --- a/sapi/cli/generate_mime_type_map.php +++ b/sapi/cli/generate_mime_type_map.php @@ -29,6 +29,7 @@ array_walk($types, function ($line) use (&$extensions) { $additional_mime_maps = [ "map" => "application/json", // from commit: a0d62f08ae8cbebc88e5c92e08fca8d0cdc7309d + "jsm" => "application/javascript", ]; foreach($additional_mime_maps as $ext => $mime) { @@ -69,7 +70,7 @@ typedef struct php_cli_server_ext_mime_type_pair { const char *mime_type; } php_cli_server_ext_mime_type_pair; -static php_cli_server_ext_mime_type_pair mime_type_map[] = { +static const php_cli_server_ext_mime_type_pair mime_type_map[] = { <?php foreach ($extensions as $extension => $mime): ?> { "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" }, <?php endforeach ?> diff --git a/sapi/cli/mime_type_map.h b/sapi/cli/mime_type_map.h index b937b6b96b..2b880b4c7f 100644 --- a/sapi/cli/mime_type_map.h +++ b/sapi/cli/mime_type_map.h @@ -27,7 +27,7 @@ typedef struct php_cli_server_ext_mime_type_pair { const char *mime_type; } php_cli_server_ext_mime_type_pair; -static php_cli_server_ext_mime_type_pair mime_type_map[] = { +static const php_cli_server_ext_mime_type_pair mime_type_map[] = { { "ez", "application/andrew-inset" }, { "aw", "application/applixware" }, { "atom", "application/atom+xml" }, @@ -635,16 +635,12 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "bdf", "application/x-font-bdf" }, { "gsf", "application/x-font-ghostscript" }, { "psf", "application/x-font-linux-psf" }, - { "otf", "application/x-font-otf" }, { "pcf", "application/x-font-pcf" }, { "snf", "application/x-font-snf" }, - { "ttf", "application/x-font-ttf" }, - { "ttc", "application/x-font-ttf" }, { "pfa", "application/x-font-type1" }, { "pfb", "application/x-font-type1" }, { "pfm", "application/x-font-type1" }, { "afm", "application/x-font-type1" }, - { "woff", "application/font-woff" }, { "arc", "application/x-freearc" }, { "spl", "application/x-futuresplash" }, { "gca", "application/x-gca-compressed" }, @@ -758,6 +754,7 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "midi", "audio/midi" }, { "kar", "audio/midi" }, { "rmi", "audio/midi" }, + { "m4a", "audio/mp4" }, { "mp4a", "audio/mp4" }, { "mpga", "audio/mpeg" }, { "mp2", "audio/mpeg" }, @@ -804,6 +801,11 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "cml", "chemical/x-cml" }, { "csml", "chemical/x-csml" }, { "xyz", "chemical/x-xyz" }, + { "ttc", "font/collection" }, + { "otf", "font/otf" }, + { "ttf", "font/ttf" }, + { "woff", "font/woff" }, + { "woff2", "font/woff2" }, { "bmp", "image/bmp" }, { "cgm", "image/cgm" }, { "g3", "image/g3fax" }, @@ -825,9 +827,9 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "uvvi", "image/vnd.dece.graphic" }, { "uvg", "image/vnd.dece.graphic" }, { "uvvg", "image/vnd.dece.graphic" }, - { "sub", "text/vnd.dvb.subtitle" }, { "djvu", "image/vnd.djvu" }, { "djv", "image/vnd.djvu" }, + { "sub", "text/vnd.dvb.subtitle" }, { "dwg", "image/vnd.dwg" }, { "dxf", "image/vnd.dxf" }, { "fbs", "image/vnd.fastbidsheet" }, @@ -917,8 +919,8 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "vcard", "text/vcard" }, { "curl", "text/vnd.curl" }, { "dcurl", "text/vnd.curl.dcurl" }, - { "scurl", "text/vnd.curl.scurl" }, { "mcurl", "text/vnd.curl.mcurl" }, + { "scurl", "text/vnd.curl.scurl" }, { "fly", "text/vnd.fly" }, { "flx", "text/vnd.fmi.flexstor" }, { "gv", "text/vnd.graphviz" }, @@ -941,10 +943,10 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "f77", "text/x-fortran" }, { "f90", "text/x-fortran" }, { "java", "text/x-java-source" }, + { "nfo", "text/x-nfo" }, { "opml", "text/x-opml" }, { "p", "text/x-pascal" }, { "pas", "text/x-pascal" }, - { "nfo", "text/x-nfo" }, { "etx", "text/x-setext" }, { "sfv", "text/x-sfv" }, { "uu", "text/x-uuencode" }, @@ -1010,6 +1012,7 @@ static php_cli_server_ext_mime_type_pair mime_type_map[] = { { "smv", "video/x-smv" }, { "ice", "x-conference/x-cooltalk" }, { "map", "application/json" }, + { "jsm", "application/javascript" }, { NULL, NULL } }; diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 86d2c6d224..3b053e223a 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -20,8 +20,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -267,13 +265,9 @@ static inline int sapi_cli_select(php_socket_t fd) return ret != -1; } -PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length) /* {{{ */ +PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /* {{{ */ { -#ifdef PHP_WRITE_STDOUT - zend_long ret; -#else - size_t ret; -#endif + ssize_t ret; if (cli_shell_callbacks.cli_shell_write) { cli_shell_callbacks.cli_shell_write(str, str_length); @@ -283,16 +277,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length) /* do { ret = write(STDOUT_FILENO, str, str_length); } while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO)); - - if (ret <= 0) { - return 0; - } - - return ret; #else ret = fwrite(str, 1, MIN(str_length, 16384), stdout); - return ret; #endif + return ret; } /* }}} */ @@ -300,7 +288,7 @@ static size_t sapi_cli_ub_write(const char *str, size_t str_length) /* {{{ */ { const char *ptr = str; size_t remaining = str_length; - size_t ret; + ssize_t ret; if (!str_length) { return 0; @@ -317,8 +305,9 @@ static size_t sapi_cli_ub_write(const char *str, size_t str_length) /* {{{ */ while (remaining > 0) { ret = sapi_cli_single_write(ptr, remaining); - if (!ret) { + if (ret < 0) { #ifndef PHP_CLI_WIN32_NO_CONSOLE + EG(exit_status) = 255; php_handle_aborted_connection(); #endif break; @@ -592,19 +581,16 @@ static void cli_register_file_handles(void) /* {{{ */ php_stream_to_zval(s_out, &oc.value); php_stream_to_zval(s_err, &ec.value); - ic.flags = CONST_CS; - ic.name = zend_string_init("STDIN", sizeof("STDIN")-1, 1); - ic.module_number = 0; + ZEND_CONSTANT_SET_FLAGS(&ic, CONST_CS, 0); + ic.name = zend_string_init_interned("STDIN", sizeof("STDIN")-1, 0); zend_register_constant(&ic); - oc.flags = CONST_CS; - oc.name = zend_string_init("STDOUT", sizeof("STDOUT")-1, 1); - oc.module_number = 0; + ZEND_CONSTANT_SET_FLAGS(&oc, CONST_CS, 0); + oc.name = zend_string_init_interned("STDOUT", sizeof("STDOUT")-1, 0); zend_register_constant(&oc); - ec.flags = CONST_CS; - ec.name = zend_string_init("STDERR", sizeof("STDERR")-1, 1); - ec.module_number = 0; + ZEND_CONSTANT_SET_FLAGS(&ec, CONST_CS, 0); + ec.name = zend_string_init_interned("STDERR", sizeof("STDERR")-1, 0); zend_register_constant(&ec); } /* }}} */ @@ -917,7 +903,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ #if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) && (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE) if (!interactive) { /* The -a option was not passed. If there is no file, it could - still make sense to run interactively. The presense of a file + still make sense to run interactively. The presence of a file is essential to mitigate buggy console info. */ interactive = php_win32_console_is_own() && !(script_file || diff --git a/sapi/cli/php_cli_process_title.c b/sapi/cli/php_cli_process_title.c index a24fbbb69e..a85370cbd5 100644 --- a/sapi/cli/php_cli_process_title.c +++ b/sapi/cli/php_cli_process_title.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -26,7 +24,7 @@ #include "php_cli_process_title.h" #include "ps_title.h" -/* {{{ proto boolean cli_set_process_title(string arg) +/* {{{ proto bool cli_set_process_title(string arg) Return a boolean to confirm if the process title was successfully changed or not */ PHP_FUNCTION(cli_set_process_title) { diff --git a/sapi/cli/php_cli_process_title.h b/sapi/cli/php_cli_process_title.h index 854dec6165..8882e3cd0e 100644 --- a/sapi/cli/php_cli_process_title.h +++ b/sapi/cli/php_cli_process_title.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef PHP_PS_TITLE_HEADER #define PHP_PS_TITLE_HEADER diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index cdcd93ac72..38cc094954 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -17,8 +17,6 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c 306938 2011-01-01 02:17:06Z felipe $ */ - #include <stdio.h> #include <stdlib.h> #include <fcntl.h> @@ -359,7 +357,7 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c smart_str_appends_ex(buffer, "Date: ", persistent); smart_str_appends_ex(buffer, dt->val, persistent); smart_str_appends_ex(buffer, " GMT\r\n", persistent); - zend_string_release(dt); + zend_string_release_ex(dt, 0); } smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent); @@ -638,10 +636,14 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */ char *tmp; if ((tmp = strrchr(client->addr_str, ':'))) { char addr[64], port[8]; + const char *addr_start = client->addr_str, *addr_end = tmp; + if (addr_start[0] == '[') addr_start++; + if (addr_end[-1] == ']') addr_end--; + strncpy(port, tmp + 1, 8); port[7] = '\0'; - strncpy(addr, client->addr_str, tmp - client->addr_str); - addr[tmp - client->addr_str] = '\0'; + strncpy(addr, addr_start, addr_end - addr_start); + addr[addr_end - addr_start] = '\0'; sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", addr); sapi_cli_server_register_variable(track_vars_array, "REMOTE_PORT", port); } else { @@ -1573,11 +1575,14 @@ static void php_cli_server_client_save_header(php_cli_server_client *client) { /* strip off the colon */ zend_string *orig_header_name = zend_string_init(client->current_header_name, client->current_header_name_len, 1); - char *lc_header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len); - zend_hash_str_add_ptr(&client->request.headers, lc_header_name, client->current_header_name_len, client->current_header_value); + zend_string *lc_header_name = zend_string_alloc(client->current_header_name_len, 1); + zend_str_tolower_copy(ZSTR_VAL(lc_header_name), client->current_header_name, client->current_header_name_len); + GC_MAKE_PERSISTENT_LOCAL(orig_header_name); + GC_MAKE_PERSISTENT_LOCAL(lc_header_name); + zend_hash_add_ptr(&client->request.headers, lc_header_name, client->current_header_value); zend_hash_add_ptr(&client->request.headers_original_case, orig_header_name, client->current_header_value); - efree(lc_header_name); - zend_string_release(orig_header_name); + zend_string_release_ex(lc_header_name, 1); + zend_string_release_ex(orig_header_name, 1); if (client->current_header_name_allocated) { pefree(client->current_header_name, 1); @@ -1831,7 +1836,7 @@ static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_ser php_network_populate_name_from_sockaddr(addr, addr_len, &addr_str, NULL, 0); client->addr_str = pestrndup(ZSTR_VAL(addr_str), ZSTR_LEN(addr_str), 1); client->addr_str_len = ZSTR_LEN(addr_str); - zend_string_release(addr_str); + zend_string_release_ex(addr_str, 0); } php_http_parser_init(&client->parser, PHP_HTTP_REQUEST); client->request_read = 0; @@ -1947,7 +1952,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server chunk = php_cli_server_chunk_heap_new(buffer.s, ZSTR_VAL(buffer.s), ZSTR_LEN(buffer.s)); if (!chunk) { - smart_str_free(&buffer); + smart_str_free_ex(&buffer, 1); goto fail; } php_cli_server_buffer_prepend(&client->content_sender.buffer, chunk); @@ -2029,9 +2034,6 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv php_cli_server_chunk *chunk; smart_str buffer = { 0 }; const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len); - if (!mime_type) { - mime_type = "application/octet-stream"; - } append_http_status_line(&buffer, client->request.protocol_version, status, 1); if (!buffer.s) { @@ -2040,19 +2042,21 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv return FAILURE; } append_essential_headers(&buffer, client, 1); - smart_str_appendl_ex(&buffer, "Content-Type: ", sizeof("Content-Type: ") - 1, 1); - smart_str_appends_ex(&buffer, mime_type, 1); - if (strncmp(mime_type, "text/", 5) == 0) { - smart_str_appends_ex(&buffer, "; charset=UTF-8", 1); + if (mime_type) { + smart_str_appendl_ex(&buffer, "Content-Type: ", sizeof("Content-Type: ") - 1, 1); + smart_str_appends_ex(&buffer, mime_type, 1); + if (strncmp(mime_type, "text/", 5) == 0) { + smart_str_appends_ex(&buffer, "; charset=UTF-8", 1); + } + smart_str_appendl_ex(&buffer, "\r\n", 2, 1); } - smart_str_appendl_ex(&buffer, "\r\n", 2, 1); smart_str_appends_ex(&buffer, "Content-Length: ", 1); smart_str_append_unsigned_ex(&buffer, client->request.sb.st_size, 1); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); smart_str_appendl_ex(&buffer, "\r\n", 2, 1); chunk = php_cli_server_chunk_heap_new(buffer.s, ZSTR_VAL(buffer.s), ZSTR_LEN(buffer.s)); if (!chunk) { - smart_str_free(&buffer); + smart_str_free_ex(&buffer, 1); php_cli_server_log_response(client, 500, NULL); return FAILURE; } @@ -2288,7 +2292,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c if (server_sock == SOCK_ERR) { php_cli_server_logf("Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?"); if (errstr) { - zend_string_release(errstr); + zend_string_release_ex(errstr, 0); } retval = FAILURE; goto out; diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h index e6d528cedb..2a68894479 100644 --- a/sapi/cli/php_cli_server.h +++ b/sapi/cli/php_cli_server.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c 306938 2011-01-01 02:17:06Z felipe $ */ - #ifndef PHP_CLI_SERVER_H #define PHP_CLI_SERVER_H diff --git a/sapi/cli/ps_title.h b/sapi/cli/ps_title.h index 69e791061c..bc18470ce1 100644 --- a/sapi/cli/ps_title.h +++ b/sapi/cli/ps_title.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef PS_TITLE_HEADER #define PS_TITLE_HEADER diff --git a/sapi/cli/tests/002-win32.phpt b/sapi/cli/tests/002-win32.phpt index d65961de8e..2895d15211 100644 --- a/sapi/cli/tests/002-win32.phpt +++ b/sapi/cli/tests/002-win32.phpt @@ -16,7 +16,7 @@ var_dump(`$php -n -r "var_dump('hello');"`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(18) "string(5) "hello" " Done diff --git a/sapi/cli/tests/002.phpt b/sapi/cli/tests/002.phpt index f273aa02d3..2be668f188 100644 --- a/sapi/cli/tests/002.phpt +++ b/sapi/cli/tests/002.phpt @@ -16,7 +16,7 @@ var_dump(`$php -n -r 'var_dump("hello");'`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(18) "string(5) "hello" " Done diff --git a/sapi/cli/tests/003-2.phpt b/sapi/cli/tests/003-2.phpt index b3fd78233e..6b8957e644 100644 --- a/sapi/cli/tests/003-2.phpt +++ b/sapi/cli/tests/003-2.phpt @@ -17,7 +17,7 @@ var_dump(`"$php" -nd max_execution_time=500 -r 'var_dump(ini_get("max_execution_ ?> ===DONE=== ---EXPECTF-- +--EXPECT-- string(16) "string(3) "111" " string(16) "string(3) "500" diff --git a/sapi/cli/tests/003.phpt b/sapi/cli/tests/003.phpt index cbba356fd3..6584e2c7be 100644 --- a/sapi/cli/tests/003.phpt +++ b/sapi/cli/tests/003.phpt @@ -19,7 +19,7 @@ var_dump(`$php -n -d upload_tmp_dir=/test/path -d max_execution_time=555 -r 'var echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(16) "string(3) "111" " string(16) "string(3) "500" diff --git a/sapi/cli/tests/004.phpt b/sapi/cli/tests/004.phpt index 3123d0dc77..78158ba70a 100644 --- a/sapi/cli/tests/004.phpt +++ b/sapi/cli/tests/004.phpt @@ -3,9 +3,6 @@ show information about function --SKIPIF-- <?php include "skipif.inc"; -if (!extension_loaded("reflection")) { - die("skip reflection extension required"); -} ?> --FILE-- <?php @@ -18,7 +15,7 @@ var_dump(`$php -n --rf phpinfo`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(45) "Exception: Function unknown() does not exist " string(42) "Exception: Function echo() does not exist diff --git a/sapi/cli/tests/005.phpt b/sapi/cli/tests/005.phpt index 3dd937b55e..0a366b6975 100644 --- a/sapi/cli/tests/005.phpt +++ b/sapi/cli/tests/005.phpt @@ -3,9 +3,6 @@ show information about class --SKIPIF-- <?php include "skipif.inc"; -if (!extension_loaded("reflection")) { - die("skip reflection extension required"); -} ?> --FILE-- <?php @@ -18,7 +15,7 @@ var_dump(`"$php" -n --rc exception`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(40) "Exception: Class unknown does not exist " string(183) "Class [ <internal:Core> class stdClass ] { diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt index a4ac0ca4cf..6a980b8c45 100644 --- a/sapi/cli/tests/006.phpt +++ b/sapi/cli/tests/006.phpt @@ -3,8 +3,11 @@ show information about extension --SKIPIF-- <?php include "skipif.inc"; -if (!extension_loaded("reflection") || !extension_loaded("session")) { - die("skip reflection and session extensions required"); +if (!extension_loaded("session")) { + die("skip session extension required"); +} +if (PCRE_JIT_SUPPORT == false) { + die ("skip not pcre jit support builtin"); } ?> --INI-- @@ -39,23 +42,26 @@ string(%d) "Extension [ <persistent> extension #%d pcre version %s ] { } } - - Constants [16] { - Constant [ integer PREG_PATTERN_ORDER ] { 1 } - Constant [ integer PREG_SET_ORDER ] { 2 } - Constant [ integer PREG_OFFSET_CAPTURE ] { 256 } - Constant [ integer PREG_UNMATCHED_AS_NULL ] { 512 } - Constant [ integer PREG_SPLIT_NO_EMPTY ] { 1 } - Constant [ integer PREG_SPLIT_DELIM_CAPTURE ] { 2 } - Constant [ integer PREG_SPLIT_OFFSET_CAPTURE ] { 4 } - Constant [ integer PREG_GREP_INVERT ] { 1 } - Constant [ integer PREG_NO_ERROR ] { 0 } - Constant [ integer PREG_INTERNAL_ERROR ] { 1 } - Constant [ integer PREG_BACKTRACK_LIMIT_ERROR ] { 2 } - Constant [ integer PREG_RECURSION_LIMIT_ERROR ] { 3 } - Constant [ integer PREG_BAD_UTF8_ERROR ] { 4 } - Constant [ integer PREG_BAD_UTF8_OFFSET_ERROR ] { 5 } - Constant [ integer PREG_JIT_STACKLIMIT_ERROR ] { 6 } + - Constants [19] { + Constant [ int PREG_PATTERN_ORDER ] { 1 } + Constant [ int PREG_SET_ORDER ] { 2 } + Constant [ int PREG_OFFSET_CAPTURE ] { 256 } + Constant [ int PREG_UNMATCHED_AS_NULL ] { 512 } + Constant [ int PREG_SPLIT_NO_EMPTY ] { 1 } + Constant [ int PREG_SPLIT_DELIM_CAPTURE ] { 2 } + Constant [ int PREG_SPLIT_OFFSET_CAPTURE ] { 4 } + Constant [ int PREG_GREP_INVERT ] { 1 } + Constant [ int PREG_NO_ERROR ] { 0 } + Constant [ int PREG_INTERNAL_ERROR ] { 1 } + Constant [ int PREG_BACKTRACK_LIMIT_ERROR ] { 2 } + Constant [ int PREG_RECURSION_LIMIT_ERROR ] { 3 } + Constant [ int PREG_BAD_UTF8_ERROR ] { 4 } + Constant [ int PREG_BAD_UTF8_OFFSET_ERROR ] { 5 } + Constant [ int PREG_JIT_STACKLIMIT_ERROR ] { 6 } Constant [ string PCRE_VERSION ] { %s } + Constant [ int PCRE_VERSION_MAJOR ] { %d } + Constant [ int PCRE_VERSION_MINOR ] { %d } + Constant [ bool PCRE_JIT_SUPPORT ] { %d } } - Functions { diff --git a/sapi/cli/tests/007.phpt b/sapi/cli/tests/007.phpt index d1af19f1d2..dd8e17163c 100644 --- a/sapi/cli/tests/007.phpt +++ b/sapi/cli/tests/007.phpt @@ -40,7 +40,7 @@ var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(81) " <?php class test { public $var = "test"; private $pri; function foo() { } } ?> diff --git a/sapi/cli/tests/009.phpt b/sapi/cli/tests/009.phpt index 54c795b0f6..c110966458 100644 --- a/sapi/cli/tests/009.phpt +++ b/sapi/cli/tests/009.phpt @@ -12,7 +12,7 @@ var_dump(`$php -n -r "echo hello;" -a`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(57) "Either execute direct code, process stdin or use a file. " string(57) "Either execute direct code, process stdin or use a file. diff --git a/sapi/cli/tests/010-2.phpt b/sapi/cli/tests/010-2.phpt index 57e0f7a47c..73198ad28b 100644 --- a/sapi/cli/tests/010-2.phpt +++ b/sapi/cli/tests/010-2.phpt @@ -27,7 +27,7 @@ var_dump(`cat "$filename_txt" | "$php" -n -R "var_dump(1);"`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(21) "int(1) int(1) int(1) diff --git a/sapi/cli/tests/010.phpt b/sapi/cli/tests/010.phpt index 2c3da0eb41..c316e213e3 100644 --- a/sapi/cli/tests/010.phpt +++ b/sapi/cli/tests/010.phpt @@ -38,7 +38,7 @@ var_dump(`cat "$filename_txt" | "$php" -n -F "$filename"`); @unlink(__DIR__."/010.test.php"); @unlink(__DIR__."/010.test.txt"); ?> ---EXPECTF-- +--EXPECT-- string(25) " string(10) "test hello" diff --git a/sapi/cli/tests/012-2.phpt b/sapi/cli/tests/012-2.phpt new file mode 100644 index 0000000000..da73fa9b26 --- /dev/null +++ b/sapi/cli/tests/012-2.phpt @@ -0,0 +1,52 @@ +--TEST-- +more invalid arguments and error messages +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +$php = getenv('TEST_PHP_EXECUTABLE'); + +// -r : behavior = CLI_DIRECT +// -F / -R / -B / -E : behavior = PROCESS_STDIN +// -l : behavior = LINT +// -s : behavior = HIGHLIGHT +// -w : behavior = STRIP + +var_dump(`"$php" -n -r "echo 1;" -F some.php`); +var_dump(`"$php" -n -r "echo 2;" -f some.php`); +var_dump(`"$php" -n -r "echo 3;" -l`); // ignores linting +var_dump(`"$php" -n -r "echo 4;" -R some.php`); +var_dump(`"$php" -n -r "echo 5;" -B ""`); +var_dump(`"$php" -n -a -B ""`); +var_dump(`"$php" -n -r "echo 6;" -E ""`); +var_dump(`"$php" -n -a -E ""`); +var_dump(`"$php" -n -r "echo 7;" -s`); +var_dump(`"$php" -n -r "echo 8;" -w`); +var_dump(`"$php" -n -l -r "echo 9;"`); + +echo "Done\n"; +?> +--EXPECT-- +string(57) "Either execute direct code, process stdin or use a file. +" +string(57) "Either execute direct code, process stdin or use a file. +" +string(1) "3" +string(57) "Either execute direct code, process stdin or use a file. +" +string(57) "Either execute direct code, process stdin or use a file. +" +string(57) "Either execute direct code, process stdin or use a file. +" +string(57) "Either execute direct code, process stdin or use a file. +" +string(57) "Either execute direct code, process stdin or use a file. +" +string(42) "Source highlighting only works for files. +" +string(39) "Source stripping only works for files. +" +string(57) "Either execute direct code, process stdin or use a file. +" +Done diff --git a/sapi/cli/tests/012.phpt b/sapi/cli/tests/012.phpt index 780e1088d0..08ec4ecb1c 100644 --- a/sapi/cli/tests/012.phpt +++ b/sapi/cli/tests/012.phpt @@ -18,7 +18,7 @@ var_dump(`"$php" -n -r '' -r ''`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(32) "You can use -R or -F only once. " string(32) "You can use -R or -F only once. diff --git a/sapi/cli/tests/013.phpt b/sapi/cli/tests/013.phpt index 6d49789382..9e17c009c2 100644 --- a/sapi/cli/tests/013.phpt +++ b/sapi/cli/tests/013.phpt @@ -23,7 +23,7 @@ var_dump(`cat "$filename_txt" | "$php" -n -B 'var_dump("start");' -E 'var_dump(" echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(18) "string(5) "start" " string(16) "string(3) "end" diff --git a/sapi/cli/tests/014.phpt b/sapi/cli/tests/014.phpt index 572c9e78cd..1794d78b54 100644 --- a/sapi/cli/tests/014.phpt +++ b/sapi/cli/tests/014.phpt @@ -34,7 +34,7 @@ var_dump(`"$php" -n -s unknown`); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(1478) "<code><span style="color: #000000"> <br /><span style="color: #0000BB"><?php<br />$test </span><span style="color: #007700">= </span><span style="color: #DD0000">"var"</span><span style="color: #007700">; </span><span style="color: #FF8000">//var<br />/* test class */<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">test </span><span style="color: #007700">{<br /> private </span><span style="color: #0000BB">$var </span><span style="color: #007700">= array();<br /><br /> public static function </span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">Test $arg</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;<br /> </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">);<br /> }<br />}<br /><br /></span><span style="color: #0000BB">$o </span><span style="color: #007700">= new </span><span style="color: #0000BB">test</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?><br /></span> </span> diff --git a/sapi/cli/tests/016.phpt b/sapi/cli/tests/016.phpt index cf9ff8c9d3..ea735d8d6e 100644 --- a/sapi/cli/tests/016.phpt +++ b/sapi/cli/tests/016.phpt @@ -59,7 +59,7 @@ foreach ($codes as $key => $code) { echo "\nDone\n"; ?> ---EXPECTF-- +--EXPECT-- -------------- Snippet no. 1: -------------- diff --git a/sapi/cli/tests/017.phpt b/sapi/cli/tests/017.phpt index cd1a1adfdc..684e41691e 100644 --- a/sapi/cli/tests/017.phpt +++ b/sapi/cli/tests/017.phpt @@ -59,7 +59,7 @@ foreach ($codes as $key => $code) { echo "\nDone\n"; ?> ---EXPECTF-- +--EXPECT-- -------------- Snippet no. 1: -------------- diff --git a/sapi/cli/tests/021.phpt b/sapi/cli/tests/021.phpt index 0edd5a81c0..a5d97c326d 100644 --- a/sapi/cli/tests/021.phpt +++ b/sapi/cli/tests/021.phpt @@ -35,7 +35,7 @@ echo "\nDone\n"; <?php unlink(__DIR__.'/021.tmp.php'); ?> ---EXPECTF-- +--EXPECT-- ola 2 adeus diff --git a/sapi/cli/tests/023.phpt b/sapi/cli/tests/023.phpt index 91674e321e..09b256a9af 100644 --- a/sapi/cli/tests/023.phpt +++ b/sapi/cli/tests/023.phpt @@ -41,6 +41,6 @@ proc_close($proc); <?php unlink(__DIR__ . "/023.ini"); ?> ---EXPECTF-- +--EXPECT-- string(3) "40M" string(0) "" diff --git a/sapi/cli/tests/bug61679.phpt b/sapi/cli/tests/bug61679.phpt index 819ce2fa89..3ba36d572c 100644 --- a/sapi/cli/tests/bug61679.phpt +++ b/sapi/cli/tests/bug61679.phpt @@ -39,5 +39,5 @@ HEADER fclose($fp); ?> ---EXPECTF-- +--EXPECT-- HTTP/1.1 501 Not Implemented diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt index 604c9babe6..1b29dea31b 100644 --- a/sapi/cli/tests/bug61977.phpt +++ b/sapi/cli/tests/bug61977.phpt @@ -43,7 +43,7 @@ HEADER; test_mimetypes($mimetypes); ?> ---EXPECTF-- +--EXPECT-- foo.html => Content-Type: text/html; charset=UTF-8 foo.htm => Content-Type: text/html; charset=UTF-8 foo.svg => Content-Type: image/svg+xml diff --git a/sapi/cli/tests/bug64544.phpt b/sapi/cli/tests/bug64544.phpt index cc49545c16..33a6e16a10 100644 --- a/sapi/cli/tests/bug64544.phpt +++ b/sapi/cli/tests/bug64544.phpt @@ -15,6 +15,6 @@ var_dump(getenv("HOME")); putenv("FOO=BAR"); var_dump(getenv("FOO")); ?> ---EXPECTF-- +--EXPECT-- string(4) "/tmp" string(3) "BAR" diff --git a/sapi/cli/tests/bug66606_1.phpt b/sapi/cli/tests/bug66606_1.phpt index 6b1b82772f..b58db6cfdd 100644 --- a/sapi/cli/tests/bug66606_1.phpt +++ b/sapi/cli/tests/bug66606_1.phpt @@ -12,6 +12,6 @@ include "php_cli_server.inc"; php_cli_server_start('var_dump($_SERVER["CONTENT_TYPE"], $_SERVER["CONTENT_LENGTH"])'); echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS); ?> ---EXPECTF-- +--EXPECT-- NULL NULL diff --git a/sapi/cli/tests/bug74600.phpt b/sapi/cli/tests/bug74600.phpt index 0ca7be95a7..eee222aaa3 100644 --- a/sapi/cli/tests/bug74600.phpt +++ b/sapi/cli/tests/bug74600.phpt @@ -33,6 +33,6 @@ proc_close($proc); <?php unlink(__DIR__ . "/bug74600.ini"); ?> ---EXPECTF-- +--EXPECT-- string(4) "okey" string(0) "" diff --git a/sapi/cli/tests/cli_get_process_title_basic.phpt b/sapi/cli/tests/cli_get_process_title_basic.phpt new file mode 100644 index 0000000000..66d1d4f3a7 --- /dev/null +++ b/sapi/cli/tests/cli_get_process_title_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +cli_get_process_title() function : basic functionality +--CREDITS-- +Patrick Allaert patrickallaert@php.net +@nephp #nephp17 +--SKIPIF-- +<?php +if (PHP_SAPI !== "cli") + die("skip"); +?> +--FILE-- +<?php +if (cli_set_process_title("title") && cli_get_process_title() === "title") + echo "Title correctly retrieved!\n"; + +?> +--EXPECT-- +Title correctly retrieved! diff --git a/sapi/cli/tests/cli_get_process_title_error.phpt b/sapi/cli/tests/cli_get_process_title_error.phpt new file mode 100644 index 0000000000..67274db26c --- /dev/null +++ b/sapi/cli/tests/cli_get_process_title_error.phpt @@ -0,0 +1,16 @@ +--TEST-- +cli_get_process_title() function : error conditions +--CREDITS-- +Patrick Allaert patrickallaert@php.net +@nephp #nephp17 +--SKIPIF-- +<?php +if (PHP_SAPI !== "cli") + die("skip"); +?> +--FILE-- +<?php +cli_get_process_title("foo"); +?> +--EXPECTF-- +Warning: cli_get_process_title() expects exactly 0 parameters, 1 given in %scli_get_process_title_error.php on line 2 diff --git a/sapi/cli/tests/cli_process_title_unix.phpt b/sapi/cli/tests/cli_process_title_unix.phpt index 659299c1fc..418433d8f2 100644 --- a/sapi/cli/tests/cli_process_title_unix.phpt +++ b/sapi/cli/tests/cli_process_title_unix.phpt @@ -47,7 +47,7 @@ else echo "Actually loaded from get: $read_title\n"; ?> ---EXPECTF-- +--EXPECT-- *** Testing setting the process title *** Successfully set title Successfully verified title using ps diff --git a/sapi/cli/tests/cli_process_title_windows.phpt b/sapi/cli/tests/cli_process_title_windows.phpt index 91bac579e8..677f43fd8b 100644 --- a/sapi/cli/tests/cli_process_title_windows.phpt +++ b/sapi/cli/tests/cli_process_title_windows.phpt @@ -66,7 +66,7 @@ else echo "Actually loaded from get: $read_title\n"; ?> ---EXPECTF-- +--EXPECT-- *** Testing setting the process title *** Successfully set title Successfully verified title using get-process diff --git a/sapi/cli/tests/cli_set_process_title_basic.phpt b/sapi/cli/tests/cli_set_process_title_basic.phpt new file mode 100644 index 0000000000..9899f3456b --- /dev/null +++ b/sapi/cli/tests/cli_set_process_title_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +cli_set_process_title() function : basic functionality +--CREDITS-- +Patrick Allaert patrickallaert@php.net +@nephp #nephp17 +--SKIPIF-- +<?php +if (PHP_SAPI !== "cli") + die("skip"); +?> +--FILE-- +<?php +if (cli_set_process_title("title") === true && + cli_get_process_title() === "title") + echo "Successfully set title\n"; + +?> +--EXPECT-- +Successfully set title diff --git a/sapi/cli/tests/cli_set_process_title_error.phpt b/sapi/cli/tests/cli_set_process_title_error.phpt new file mode 100644 index 0000000000..025c73015b --- /dev/null +++ b/sapi/cli/tests/cli_set_process_title_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +cli_set_process_title() function : error conditions +--CREDITS-- +Patrick Allaert patrickallaert@php.net +@nephp #nephp17 +--SKIPIF-- +<?php +if (PHP_SAPI !== "cli") + die("skip"); +?> +--FILE-- +<?php +cli_set_process_title(); +cli_set_process_title("foo", "bar"); +?> +--EXPECTF-- +Warning: cli_set_process_title() expects exactly 1 parameter, 0 given in %scli_set_process_title_error.php on line 2 + +Warning: cli_set_process_title() expects exactly 1 parameter, 2 given in %scli_set_process_title_error.php on line 3 diff --git a/sapi/cli/tests/php_cli_server_003.phpt b/sapi/cli/tests/php_cli_server_003.phpt index e763c7ac34..f8aa94edf6 100644 --- a/sapi/cli/tests/php_cli_server_003.phpt +++ b/sapi/cli/tests/php_cli_server_003.phpt @@ -13,6 +13,6 @@ php_cli_server_start('chdir(__DIR__); echo "okey";'); var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS)); var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS)); ?> ---EXPECTF-- +--EXPECT-- string(4) "okey" string(4) "okey" diff --git a/sapi/cli/tests/php_cli_server_016.phpt b/sapi/cli/tests/php_cli_server_016.phpt index 855acd5ec3..ae1d3f272a 100644 --- a/sapi/cli/tests/php_cli_server_016.phpt +++ b/sapi/cli/tests/php_cli_server_016.phpt @@ -42,5 +42,5 @@ HEADER fclose($fp); ?> ---EXPECTF-- +--EXPECT-- HTTP/1.1 404 Not Found diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt index 21dacb439a..34e3a7c288 100644 --- a/sapi/cli/tests/upload_2G.phpt +++ b/sapi/cli/tests/upload_2G.phpt @@ -78,7 +78,6 @@ fclose($fp); Done --EXPECTF-- Test - HTTP/1.1 200 OK Host: %s Date: %s diff --git a/sapi/embed/config.m4 b/sapi/embed/config.m4 index dcdb4d68aa..78e2d15775 100644 --- a/sapi/embed/config.m4 +++ b/sapi/embed/config.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi embed PHP_ARG_ENABLE(embed,, [ --enable-embed[=TYPE] EXPERIMENTAL: Enable building of embedded SAPI library diff --git a/sapi/embed/config.w32 b/sapi/embed/config.w32 index ce41e253f0..394982126c 100644 --- a/sapi/embed/config.w32 +++ b/sapi/embed/config.w32 @@ -1,5 +1,4 @@ // vim:ft=javascript -// $Id$ ARG_ENABLE('embed', 'Embedded SAPI library', 'no'); diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index c279c9e372..d93149b462 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -15,7 +15,6 @@ | Author: Edin Kadribasic <edink@php.net> | +----------------------------------------------------------------------+ */ -/* $Id$ */ #include "php_embed.h" #include "ext/standard/php_standard.h" diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index 7f35e623a2..15c311e2b3 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -15,7 +15,6 @@ | Author: Edin Kadribasic <edink@php.net> | +----------------------------------------------------------------------+ */ -/* $Id$ */ #ifndef _PHP_EMBED_H_ #define _PHP_EMBED_H_ diff --git a/sapi/fpm/.gitignore b/sapi/fpm/.gitignore deleted file mode 100644 index 3f8c0913a4..0000000000 --- a/sapi/fpm/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -php-fpm.8 -php-fpm.service -status.html -www.conf diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 4cf4ba4972..44d842b285 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi fpm PHP_ARG_ENABLE(fpm,, [ --enable-fpm Enable building of the fpm SAPI executable], no, no) @@ -8,7 +6,7 @@ PHP_ARG_ENABLE(fpm,, dnl configure checks {{{ AC_DEFUN([AC_FPM_STDLIBS], [ - AC_CHECK_FUNCS(setenv clearenv setproctitle) + AC_CHECK_FUNCS(setenv clearenv setproctitle setproctitle_fast) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(inet_addr, nsl) @@ -23,7 +21,7 @@ AC_DEFUN([AC_FPM_PRCTL], [ AC_MSG_CHECKING([for prctl]) - AC_TRY_COMPILE([ #include <sys/prctl.h> ], [prctl(0, 0, 0, 0, 0);], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/prctl.h>]], [[prctl(0, 0, 0, 0, 0);]])], [ AC_DEFINE([HAVE_PRCTL], 1, [do we have prctl?]) AC_MSG_RESULT([yes]) ], [ @@ -37,7 +35,7 @@ AC_DEFUN([AC_FPM_CLOCK], AC_MSG_CHECKING([for clock_gettime]) - AC_TRY_LINK([ #include <time.h> ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);]])], [ have_clock_gettime=yes AC_MSG_RESULT([yes]) ], [ @@ -50,7 +48,7 @@ AC_DEFUN([AC_FPM_CLOCK], SAVED_LIBS="$LIBS" LIBS="$LIBS -lrt" - AC_TRY_LINK([ #include <time.h> ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);]])], [ have_clock_gettime=yes AC_MSG_RESULT([yes]) ], [ @@ -68,7 +66,7 @@ AC_DEFUN([AC_FPM_CLOCK], if test "$have_clock_gettime" = "no"; then AC_MSG_CHECKING([for clock_get_time]) - AC_TRY_RUN([ #include <mach/mach.h> + AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <mach/mach.h> #include <mach/clock.h> #include <mach/mach_error.h> @@ -88,12 +86,12 @@ AC_DEFUN([AC_FPM_CLOCK], return 0; } - ], [ + ]])], [ have_clock_get_time=yes AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) - ]) + ], [AC_MSG_RESULT([no (cross-compiling)])]) fi if test "$have_clock_get_time" = "yes"; then @@ -108,9 +106,9 @@ AC_DEFUN([AC_FPM_TRACE], AC_MSG_CHECKING([for ptrace]) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> - #include <sys/ptrace.h> ], [ptrace(0, 0, (void *) 0, 0);], [ + #include <sys/ptrace.h> ]], [[ptrace(0, 0, (void *) 0, 0);]])], [ have_ptrace=yes AC_MSG_RESULT([yes]) ], [ @@ -120,7 +118,7 @@ AC_DEFUN([AC_FPM_TRACE], if test "$have_ptrace" = "yes"; then AC_MSG_CHECKING([whether ptrace works]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <unistd.h> #include <signal.h> #include <sys/wait.h> @@ -187,14 +185,14 @@ AC_DEFUN([AC_FPM_TRACE], return 0; } } - ], [ + ]])], [ AC_MSG_RESULT([yes]) ], [ have_ptrace=no have_broken_ptrace=yes AC_MSG_RESULT([no]) ], [ - AC_MSG_RESULT([skipped (cross compiling)]) + AC_MSG_RESULT([skipped (cross-compiling)]) ]) fi @@ -207,11 +205,11 @@ AC_DEFUN([AC_FPM_TRACE], if test "$have_broken_ptrace" = "yes"; then AC_MSG_CHECKING([for mach_vm_read]) - AC_TRY_COMPILE([ #include <mach/mach.h> + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach/mach.h> #include <mach/mach_vm.h> - ], [ + ]], [[ mach_vm_read((vm_map_t)0, (mach_vm_address_t)0, (mach_vm_size_t)0, (vm_offset_t *)0, (mach_msg_type_number_t*)0); - ], [ + ]])], [ have_mach_vm_read=yes AC_MSG_RESULT([yes]) ], [ @@ -236,7 +234,7 @@ AC_DEFUN([AC_FPM_TRACE], if test -n "$proc_mem_file" ; then AC_MSG_CHECKING([for proc mem file]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #define _GNU_SOURCE #define _FILE_OFFSET_BITS 64 #include <stdint.h> @@ -262,13 +260,13 @@ AC_DEFUN([AC_FPM_TRACE], close(fd); return v1 != v2; } - ], [ + ]])], [ AC_MSG_RESULT([$proc_mem_file]) ], [ proc_mem_file="" AC_MSG_RESULT([no]) ], [ - AC_MSG_RESULT([skipped (cross compiling)]) + AC_MSG_RESULT([skipped (cross-compiling)]) ]) fi @@ -296,17 +294,14 @@ AC_DEFUN([AC_FPM_TRACE], AC_DEFUN([AC_FPM_BUILTIN_ATOMIC], [ AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap]) - AC_TRY_LINK(, - [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[ int variable = 1; return (__sync_bool_compare_and_swap(&variable, 1, 2) && __sync_add_and_fetch(&variable, 1)) ? 1 : 0; - ], - [ + ]])], [ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o.]) - ], - [ + ], [ AC_MSG_RESULT([no]) ]) ]) @@ -317,7 +312,7 @@ AC_DEFUN([AC_FPM_LQ], AC_MSG_CHECKING([for TCP_INFO]) - AC_TRY_COMPILE([ #include <netinet/tcp.h> ], [struct tcp_info ti; int x = TCP_INFO;], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/tcp.h>]], [[struct tcp_info ti; int x = TCP_INFO;]])], [ have_lq=tcp_info AC_MSG_RESULT([yes]) ], [ @@ -331,7 +326,7 @@ AC_DEFUN([AC_FPM_LQ], if test "$have_lq" = "no" ; then AC_MSG_CHECKING([for SO_LISTENQLEN]) - AC_TRY_COMPILE([ #include <sys/socket.h> ], [int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;]])], [ have_lq=so_listenq AC_MSG_RESULT([yes]) ], [ @@ -349,7 +344,7 @@ AC_DEFUN([AC_FPM_SYSCONF], [ AC_MSG_CHECKING([for sysconf]) - AC_TRY_COMPILE([ #include <unistd.h> ], [sysconf(_SC_CLK_TCK);], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[sysconf(_SC_CLK_TCK);]])],[ AC_DEFINE([HAVE_SYSCONF], 1, [do we have sysconf?]) AC_MSG_RESULT([yes]) ], [ @@ -362,7 +357,7 @@ AC_DEFUN([AC_FPM_TIMES], [ AC_MSG_CHECKING([for times]) - AC_TRY_COMPILE([ #include <sys/times.h> ], [struct tms t; times(&t);], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/times.h>]], [[struct tms t; times(&t);]])],[ AC_DEFINE([HAVE_TIMES], 1, [do we have times?]) AC_MSG_RESULT([yes]) ], [ @@ -375,18 +370,17 @@ AC_DEFUN([AC_FPM_KQUEUE], [ AC_MSG_CHECKING([for kqueue]) - AC_TRY_COMPILE( - [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> - ], [ + ]], [[ int kfd; struct kevent k; kfd = kqueue(); /* 0 -> STDIN_FILENO */ EV_SET(&k, 0, EVFILT_READ , EV_ADD | EV_CLEAR, 0, 0, NULL); - ], [ + ]])], [ AC_DEFINE([HAVE_KQUEUE], 1, [do we have kqueue?]) AC_MSG_RESULT([yes]) ], [ @@ -399,17 +393,16 @@ AC_DEFUN([AC_FPM_PORT], [ AC_MSG_CHECKING([for port framework]) - AC_TRY_COMPILE( - [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <port.h> - ], [ + ]], [[ int port; port = port_create(); if (port < 0) { return 1; } - ], [ + ]])], [ AC_DEFINE([HAVE_PORT], 1, [do we have port framework?]) AC_MSG_RESULT([yes]) ], [ @@ -422,11 +415,10 @@ AC_DEFUN([AC_FPM_DEVPOLL], [ AC_MSG_CHECKING([for /dev/poll]) - AC_TRY_COMPILE( - [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> #include <sys/devpoll.h> - ], [ + ]], [[ int n, dp; struct dvpoll dvp; dp = 0; @@ -434,7 +426,7 @@ AC_DEFUN([AC_FPM_DEVPOLL], dvp.dp_nfds = 0; dvp.dp_timeout = 0; n = ioctl(dp, DP_POLL, &dvp) - ], [ + ]])], [ AC_DEFINE([HAVE_DEVPOLL], 1, [do we have /dev/poll?]) AC_MSG_RESULT([yes]) ], [ @@ -447,10 +439,9 @@ AC_DEFUN([AC_FPM_EPOLL], [ AC_MSG_CHECKING([for epoll]) - AC_TRY_COMPILE( - [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/epoll.h> - ], [ + ]], [[ int epollfd; struct epoll_event e; @@ -470,7 +461,7 @@ AC_DEFUN([AC_FPM_EPOLL], if (epoll_wait(epollfd, &e, 1, 1) < 0) { return 1; } - ], [ + ]])], [ AC_DEFINE([HAVE_EPOLL], 1, [do we have epoll?]) AC_MSG_RESULT([yes]) ], [ @@ -483,10 +474,9 @@ AC_DEFUN([AC_FPM_POLL], [ AC_MSG_CHECKING([for poll]) - AC_TRY_COMPILE( - [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <poll.h> - ], [ + ]], [[ struct pollfd fds[2]; fds[0].fd = 0; @@ -496,7 +486,7 @@ AC_DEFUN([AC_FPM_POLL], fds[1].events = POLLIN; poll(fds, 2, 1); - ], [ + ]])], [ AC_DEFINE([HAVE_POLL], 1, [do we have poll?]) AC_MSG_RESULT([yes]) ], [ @@ -509,8 +499,7 @@ AC_DEFUN([AC_FPM_SELECT], [ AC_MSG_CHECKING([for select]) - AC_TRY_COMPILE( - [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* According to POSIX.1-2001 */ #include <sys/select.h> @@ -518,7 +507,7 @@ AC_DEFUN([AC_FPM_SELECT], #include <sys/time.h> #include <sys/types.h> #include <unistd.h> - ], [ + ]], [[ fd_set fds; struct timeval t; t.tv_sec = 0; @@ -527,7 +516,7 @@ AC_DEFUN([AC_FPM_SELECT], /* 0 -> STDIN_FILENO */ FD_SET(0, &fds); select(FD_SETSIZE, &fds, NULL, NULL, &t); - ], [ + ]])], [ AC_DEFINE([HAVE_SELECT], 1, [do we have select?]) AC_MSG_RESULT([yes]) ], [ @@ -543,7 +532,7 @@ AC_DEFUN([AC_FPM_APPARMOR], SAVED_LIBS="$LIBS" LIBS="$LIBS -lapparmor" - AC_TRY_LINK([ #include <sys/apparmor.h> ], [change_hat("test", 0);], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/apparmor.h>]], [[change_hat("test", 0);]])], [ AC_DEFINE([HAVE_APPARMOR], 1, [do we have apparmor support?]) AC_MSG_RESULT([yes]) ], [ diff --git a/sapi/fpm/fpm/events/devpoll.c b/sapi/fpm/fpm/events/devpoll.c index fe6f93f794..e3f73bf126 100644 --- a/sapi/fpm/fpm/events/devpoll.c +++ b/sapi/fpm/fpm/events/devpoll.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "../fpm_config.h" #include "../fpm_events.h" #include "../fpm.h" diff --git a/sapi/fpm/fpm/events/devpoll.h b/sapi/fpm/fpm/events/devpoll.h index 91599e4fb7..08730744ab 100644 --- a/sapi/fpm/fpm/events/devpoll.h +++ b/sapi/fpm/fpm/events/devpoll.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef FPM_EVENTS_DEVPOLL_H #define FPM_EVENTS_DEVPOLL_H diff --git a/sapi/fpm/fpm/events/epoll.c b/sapi/fpm/fpm/events/epoll.c index c7b47375e9..e4a3300e4d 100644 --- a/sapi/fpm/fpm/events/epoll.c +++ b/sapi/fpm/fpm/events/epoll.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "../fpm_config.h" #include "../fpm_events.h" #include "../fpm.h" diff --git a/sapi/fpm/fpm/events/epoll.h b/sapi/fpm/fpm/events/epoll.h index 696f56cdfc..4896178a58 100644 --- a/sapi/fpm/fpm/events/epoll.h +++ b/sapi/fpm/fpm/events/epoll.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef FPM_EVENTS_EPOLL_H #define FPM_EVENTS_EPOLL_H diff --git a/sapi/fpm/fpm/events/kqueue.c b/sapi/fpm/fpm/events/kqueue.c index 87eb5d7f70..f0bb98ec21 100644 --- a/sapi/fpm/fpm/events/kqueue.c +++ b/sapi/fpm/fpm/events/kqueue.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "../fpm_config.h" #include "../fpm_events.h" #include "../fpm.h" diff --git a/sapi/fpm/fpm/events/kqueue.h b/sapi/fpm/fpm/events/kqueue.h index 7255c5cae7..abb329e980 100644 --- a/sapi/fpm/fpm/events/kqueue.h +++ b/sapi/fpm/fpm/events/kqueue.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef FPM_EVENTS_KQUEUE_H #define FPM_EVENTS_KQUEUE_H diff --git a/sapi/fpm/fpm/events/poll.c b/sapi/fpm/fpm/events/poll.c index b9f62b8499..28bcf0c403 100644 --- a/sapi/fpm/fpm/events/poll.c +++ b/sapi/fpm/fpm/events/poll.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "../fpm_config.h" #include "../fpm_events.h" #include "../fpm.h" diff --git a/sapi/fpm/fpm/events/poll.h b/sapi/fpm/fpm/events/poll.h index 983077060f..c8cac2b367 100644 --- a/sapi/fpm/fpm/events/poll.h +++ b/sapi/fpm/fpm/events/poll.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef FPM_EVENTS_POLL_H #define FPM_EVENTS_POLL_H diff --git a/sapi/fpm/fpm/events/port.c b/sapi/fpm/fpm/events/port.c index 7940285dfa..bb9441369c 100644 --- a/sapi/fpm/fpm/events/port.c +++ b/sapi/fpm/fpm/events/port.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "../fpm_config.h" #include "../fpm_events.h" #include "../fpm.h" diff --git a/sapi/fpm/fpm/events/port.h b/sapi/fpm/fpm/events/port.h index 210112c450..28aee47f02 100644 --- a/sapi/fpm/fpm/events/port.h +++ b/sapi/fpm/fpm/events/port.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef FPM_EVENTS_PORT_H #define FPM_EVENTS_PORT_H diff --git a/sapi/fpm/fpm/events/select.c b/sapi/fpm/fpm/events/select.c index 5f1a02abf2..c0fd8bc085 100644 --- a/sapi/fpm/fpm/events/select.c +++ b/sapi/fpm/fpm/events/select.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #include "../fpm_config.h" #include "../fpm_events.h" #include "../fpm.h" diff --git a/sapi/fpm/fpm/events/select.h b/sapi/fpm/fpm/events/select.h index cad01df3fc..6490fe2c18 100644 --- a/sapi/fpm/fpm/events/select.h +++ b/sapi/fpm/fpm/events/select.h @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef FPM_EVENTS_SELECT_H #define FPM_EVENTS_SELECT_H diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index 2bd890b224..30cb9da010 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -1,4 +1,3 @@ - /* $Id: fpm.c,v 1.23 2008/07/20 16:38:31 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h index 5ac3ea9106..f0610ca46d 100644 --- a/sapi/fpm/fpm/fpm.h +++ b/sapi/fpm/fpm/fpm.h @@ -1,4 +1,3 @@ - /* $Id: fpm.h,v 1.13 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_H diff --git a/sapi/fpm/fpm/fpm_arrays.h b/sapi/fpm/fpm/fpm_arrays.h index 6975ab21af..82c7cbc09e 100644 --- a/sapi/fpm/fpm/fpm_arrays.h +++ b/sapi/fpm/fpm/fpm_arrays.h @@ -1,4 +1,3 @@ - /* $Id: fpm_arrays.h,v 1.2 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_ARRAYS_H diff --git a/sapi/fpm/fpm/fpm_atomic.h b/sapi/fpm/fpm/fpm_atomic.h index 7b17df6bc1..ec9e4f197d 100644 --- a/sapi/fpm/fpm/fpm_atomic.h +++ b/sapi/fpm/fpm/fpm_atomic.h @@ -1,4 +1,3 @@ - /* $Id: fpm_atomic.h,v 1.3 2008/09/18 23:34:11 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_ATOMIC_H diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index eed0c6757a..82c749fc81 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -1,4 +1,3 @@ - /* $Id: fpm_children.c,v 1.32.2.2 2008/12/13 03:21:18 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -57,6 +56,10 @@ static struct fpm_child_s *fpm_child_alloc() /* {{{ */ static void fpm_child_free(struct fpm_child_s *child) /* {{{ */ { + if (child->log_stream) { + zlog_stream_close(child->log_stream); + free(child->log_stream); + } free(child); } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_children.h b/sapi/fpm/fpm/fpm_children.h index a488b544fd..9d9c1fa7cb 100644 --- a/sapi/fpm/fpm/fpm_children.h +++ b/sapi/fpm/fpm/fpm_children.h @@ -1,4 +1,3 @@ - /* $Id: fpm_children.h,v 1.9 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_CHILDREN_H @@ -9,6 +8,7 @@ #include "fpm_worker_pool.h" #include "fpm_events.h" +#include "zlog.h" int fpm_children_create_initial(struct fpm_worker_pool_s *wp); int fpm_children_free(struct fpm_child_s *child); @@ -30,6 +30,7 @@ struct fpm_child_s { int idle_kill; pid_t pid; int scoreboard_i; + struct zlog_stream *log_stream; }; #endif diff --git a/sapi/fpm/fpm/fpm_cleanup.c b/sapi/fpm/fpm/fpm_cleanup.c index dbab8ed786..7c900974a9 100644 --- a/sapi/fpm/fpm/fpm_cleanup.c +++ b/sapi/fpm/fpm/fpm_cleanup.c @@ -1,4 +1,3 @@ - /* $Id: fpm_cleanup.c,v 1.8 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_cleanup.h b/sapi/fpm/fpm/fpm_cleanup.h index 71639afe94..8583143fa2 100644 --- a/sapi/fpm/fpm/fpm_cleanup.h +++ b/sapi/fpm/fpm/fpm_cleanup.h @@ -1,4 +1,3 @@ - /* $Id: fpm_cleanup.h,v 1.5 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_CLEANUP_H diff --git a/sapi/fpm/fpm/fpm_clock.c b/sapi/fpm/fpm/fpm_clock.c index b03531ff24..8568d7928f 100644 --- a/sapi/fpm/fpm/fpm_clock.c +++ b/sapi/fpm/fpm/fpm_clock.c @@ -1,4 +1,3 @@ - /* $Id: fpm_clock.c,v 1.4 2008/09/18 23:19:59 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_clock.h b/sapi/fpm/fpm/fpm_clock.h index 7f62d0055f..cf92521dcc 100644 --- a/sapi/fpm/fpm/fpm_clock.h +++ b/sapi/fpm/fpm/fpm_clock.h @@ -1,4 +1,3 @@ - /* $Id: fpm_clock.h,v 1.2 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_CLOCK_H diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 88959eebc6..7a05286309 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1,4 +1,3 @@ - /* $Id: fpm_conf.c,v 1.33.2.3 2008/12/13 03:50:29 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -16,11 +15,7 @@ # include <stdint.h> #endif #ifdef HAVE_GLOB -# ifndef PHP_WIN32 -# include <glob.h> -# else -# include "win32/glob.h" -# endif +# include <glob.h> #endif #include <stdio.h> @@ -80,6 +75,8 @@ struct fpm_global_config_s fpm_global_config = { .systemd_watchdog = 0, .systemd_interval = -1, /* -1 means not set */ #endif + .log_buffering = ZLOG_DEFAULT_BUFFERING, + .log_limit = ZLOG_DEFAULT_LIMIT }; static struct fpm_worker_pool_s *current_wp = NULL; static int ini_recursion = 0; @@ -97,7 +94,9 @@ static struct ini_value_parser_s ini_fpm_global_options[] = { { "syslog.ident", &fpm_conf_set_string, GO(syslog_ident) }, { "syslog.facility", &fpm_conf_set_syslog_facility, GO(syslog_facility) }, #endif + { "log_buffering", &fpm_conf_set_boolean, GO(log_buffering) }, { "log_level", &fpm_conf_set_log_level, GO(log_level) }, + { "log_limit", &fpm_conf_set_integer, GO(log_limit) }, { "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) }, @@ -148,11 +147,13 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = { { "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) }, { "request_slowlog_trace_depth", &fpm_conf_set_integer, WPO(request_slowlog_trace_depth) }, { "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) }, + { "request_terminate_timeout_track_finished", &fpm_conf_set_boolean, WPO(request_terminate_timeout_track_finished) }, { "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) }, + { "decorate_workers_output", &fpm_conf_set_boolean, WPO(decorate_workers_output) }, { "clear_env", &fpm_conf_set_boolean, WPO(clear_env) }, { "security.limit_extensions", &fpm_conf_set_string, WPO(security_limit_extensions) }, #ifdef HAVE_APPARMOR @@ -616,6 +617,7 @@ static void *fpm_worker_pool_config_alloc() /* {{{ */ wp->config->process_priority = 64; /* 64 means unset */ wp->config->process_dumpable = 0; wp->config->clear_env = 1; + wp->config->decorate_workers_output = 1; if (!fpm_worker_all_pools) { fpm_worker_all_pools = wp; @@ -1192,6 +1194,12 @@ static int fpm_conf_post_process(int force_daemon) /* {{{ */ fpm_globals.log_level = fpm_global_config.log_level; zlog_set_level(fpm_globals.log_level); + if (fpm_global_config.log_limit < ZLOG_MIN_LIMIT) { + zlog(ZLOG_ERROR, "log_limit must be greater than %d", ZLOG_MIN_LIMIT); + return -1; + } + zlog_set_limit(fpm_global_config.log_limit); + zlog_set_buffering(fpm_global_config.log_buffering); if (fpm_global_config.process_max < 0) { zlog(ZLOG_ERROR, "process_max can't be negative"); @@ -1265,6 +1273,7 @@ static void fpm_conf_cleanup(int which, void *arg) /* {{{ */ free(fpm_global_config.events_mechanism); fpm_global_config.pid_file = 0; fpm_global_config.error_log = 0; + fpm_global_config.log_limit = ZLOG_DEFAULT_LIMIT; #ifdef HAVE_SYSLOG_H free(fpm_global_config.syslog_ident); fpm_global_config.syslog_ident = 0; @@ -1606,7 +1615,9 @@ static void fpm_conf_dump() /* {{{ */ zlog(ZLOG_NOTICE, "\tsyslog.ident = %s", STR2STR(fpm_global_config.syslog_ident)); zlog(ZLOG_NOTICE, "\tsyslog.facility = %d", fpm_global_config.syslog_facility); /* FIXME: convert to string */ #endif + zlog(ZLOG_NOTICE, "\tlog_buffering = %s", BOOL2STR(fpm_global_config.log_buffering)); zlog(ZLOG_NOTICE, "\tlog_level = %s", zlog_get_level_name(fpm_globals.log_level)); + zlog(ZLOG_NOTICE, "\tlog_limit = %d", fpm_global_config.log_limit); 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, "\tprocess_control_timeout = %ds", fpm_global_config.process_control_timeout); @@ -1664,11 +1675,13 @@ static void fpm_conf_dump() /* {{{ */ zlog(ZLOG_NOTICE, "\trequest_slowlog_timeout = %ds", wp->config->request_slowlog_timeout); zlog(ZLOG_NOTICE, "\trequest_slowlog_trace_depth = %d", wp->config->request_slowlog_trace_depth); zlog(ZLOG_NOTICE, "\trequest_terminate_timeout = %ds", wp->config->request_terminate_timeout); + zlog(ZLOG_NOTICE, "\trequest_terminate_timeout_track_finished = %s", BOOL2STR(wp->config->request_terminate_timeout_track_finished)); zlog(ZLOG_NOTICE, "\trlimit_files = %d", wp->config->rlimit_files); zlog(ZLOG_NOTICE, "\trlimit_core = %d", wp->config->rlimit_core); zlog(ZLOG_NOTICE, "\tchroot = %s", STR2STR(wp->config->chroot)); zlog(ZLOG_NOTICE, "\tchdir = %s", STR2STR(wp->config->chdir)); zlog(ZLOG_NOTICE, "\tcatch_workers_output = %s", BOOL2STR(wp->config->catch_workers_output)); + zlog(ZLOG_NOTICE, "\tdecorate_workers_output = %s", BOOL2STR(wp->config->decorate_workers_output)); zlog(ZLOG_NOTICE, "\tclear_env = %s", BOOL2STR(wp->config->clear_env)); zlog(ZLOG_NOTICE, "\tsecurity.limit_extensions = %s", wp->config->security_limit_extensions); diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h index 2f11953367..42fa3cca2e 100644 --- a/sapi/fpm/fpm/fpm_conf.h +++ b/sapi/fpm/fpm/fpm_conf.h @@ -1,4 +1,3 @@ - /* $Id: fpm_conf.h,v 1.12.2.2 2008/12/13 03:46:49 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_CONF_H @@ -30,6 +29,8 @@ struct fpm_global_config_s { int syslog_facility; #endif int log_level; + int log_limit; + int log_buffering; int emergency_restart_threshold; int emergency_restart_interval; int process_control_timeout; @@ -80,11 +81,13 @@ struct fpm_worker_pool_config_s { int request_slowlog_timeout; int request_slowlog_trace_depth; int request_terminate_timeout; + int request_terminate_timeout_track_finished; int rlimit_files; int rlimit_core; char *chroot; char *chdir; int catch_workers_output; + int decorate_workers_output; int clear_env; char *security_limit_extensions; struct key_value_s *env; diff --git a/sapi/fpm/fpm/fpm_config.h b/sapi/fpm/fpm/fpm_config.h index 78768ed214..548202fe3a 100644 --- a/sapi/fpm/fpm/fpm_config.h +++ b/sapi/fpm/fpm/fpm_config.h @@ -1,4 +1,3 @@ -/* $Id: fpm_config.h,v 1.16 2008/05/25 00:30:43 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include <php_config.h> diff --git a/sapi/fpm/fpm/fpm_env.c b/sapi/fpm/fpm/fpm_env.c index 0581577115..ef7c980efb 100644 --- a/sapi/fpm/fpm/fpm_env.c +++ b/sapi/fpm/fpm/fpm_env.c @@ -1,4 +1,3 @@ - /* $Id: fpm_env.c,v 1.15 2008/09/18 23:19:59 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -119,7 +118,9 @@ static char * nvmatch(char *s1, char *s2) /* {{{ */ void fpm_env_setproctitle(char *title) /* {{{ */ { -#ifdef HAVE_SETPROCTITLE +#if defined(HAVE_SETPROCTITLE_FAST) + setproctitle_fast("%s", title); +#elif defined(HAVE_SETPROCTITLE) setproctitle("%s", title); #else #ifdef __linux__ diff --git a/sapi/fpm/fpm/fpm_env.h b/sapi/fpm/fpm/fpm_env.h index 24ff84b6f0..d767608740 100644 --- a/sapi/fpm/fpm/fpm_env.h +++ b/sapi/fpm/fpm/fpm_env.h @@ -1,4 +1,3 @@ - /* $Id: fpm_env.h,v 1.9 2008/09/18 23:19:59 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_ENV_H diff --git a/sapi/fpm/fpm/fpm_events.c b/sapi/fpm/fpm/fpm_events.c index 3917a9658c..81db9f8867 100644 --- a/sapi/fpm/fpm/fpm_events.c +++ b/sapi/fpm/fpm/fpm_events.c @@ -1,4 +1,3 @@ - /* $Id: fpm_events.c,v 1.21.2.2 2008/12/13 03:21:18 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -35,6 +34,7 @@ #define fpm_event_set_timeout(ev, now) timeradd(&(now), &(ev)->frequency, &(ev)->timeout); static void fpm_event_cleanup(int which, void *arg); +static void fpm_postponed_children_bury(struct fpm_event_s *ev, short which, void *arg); static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg); static struct fpm_event_s *fpm_event_queue_isset(struct fpm_event_queue_s *queue, struct fpm_event_s *ev); static int fpm_event_queue_add(struct fpm_event_queue_s **queue, struct fpm_event_s *ev); @@ -44,6 +44,7 @@ static void fpm_event_queue_destroy(struct fpm_event_queue_s **queue); static struct fpm_event_module_s *module; static struct fpm_event_queue_s *fpm_event_queue_timer = NULL; static struct fpm_event_queue_s *fpm_event_queue_fd = NULL; +static struct fpm_event_s children_bury_timer; static void fpm_event_cleanup(int which, void *arg) /* {{{ */ { @@ -52,6 +53,12 @@ static void fpm_event_cleanup(int which, void *arg) /* {{{ */ } /* }}} */ +static void fpm_postponed_children_bury(struct fpm_event_s *ev, short which, void *arg) /* {{{ */ +{ + fpm_children_bury(); +} +/* }}} */ + static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg) /* {{{ */ { char c; @@ -73,7 +80,12 @@ static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg) /* {{ switch (c) { case 'C' : /* SIGCHLD */ zlog(ZLOG_DEBUG, "received SIGCHLD"); - fpm_children_bury(); + /* epoll_wait() may report signal fd before read events for a finished child + * in the same bunch of events. Prevent immediate free of the child structure + * and so the fpm_event_s instance. Otherwise use after free happens during + * attemp to process following read event. */ + fpm_event_set_timer(&children_bury_timer, 0, &fpm_postponed_children_bury, NULL); + fpm_event_add(&children_bury_timer, 0); break; case 'I' : /* SIGINT */ zlog(ZLOG_DEBUG, "received SIGINT"); diff --git a/sapi/fpm/fpm/fpm_events.h b/sapi/fpm/fpm/fpm_events.h index 7e2c925345..e97ede0824 100644 --- a/sapi/fpm/fpm/fpm_events.h +++ b/sapi/fpm/fpm/fpm_events.h @@ -1,4 +1,3 @@ - /* $Id: fpm_events.h,v 1.9 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_EVENTS_H diff --git a/sapi/fpm/fpm/fpm_log.c b/sapi/fpm/fpm/fpm_log.c index cdfec8c5e0..a09e80a490 100644 --- a/sapi/fpm/fpm/fpm_log.c +++ b/sapi/fpm/fpm/fpm_log.c @@ -1,4 +1,3 @@ - /* $Id: fpm_status.c 312262 2011-06-18 17:41:56Z felipe $ */ /* (c) 2009 Jerome Loyet */ #include "php.h" diff --git a/sapi/fpm/fpm/fpm_log.h b/sapi/fpm/fpm/fpm_log.h index e3121777f0..edad81de21 100644 --- a/sapi/fpm/fpm/fpm_log.h +++ b/sapi/fpm/fpm/fpm_log.h @@ -1,4 +1,3 @@ - /* $Id: fpm_status.h 312263 2011-06-18 17:46:16Z felipe $ */ /* (c) 2009 Jerome Loyet */ #ifndef FPM_LOG_H diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index f0cc3a07a4..483fabe9d8 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -14,15 +14,13 @@ +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | | Stig Bakken <ssb@php.net> | - | Zeev Suraski <zeev@zend.com> | + | Zeev Suraski <zeev@php.net> | | FastCGI: Ben Mansell <php@slimyhorror.com> | | Shane Caraveo <shane@caraveo.com> | - | Dmitry Stogov <dmitry@zend.com> | + | Dmitry Stogov <dmitry@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: cgi_main.c 291497 2009-11-30 14:43:22Z dmitry $ */ - #include "php.h" #include "php_globals.h" #include "php_variables.h" @@ -37,12 +35,6 @@ #include <stdio.h> #include "php.h" -#ifdef PHP_WIN32 -# include "win32/time.h" -# include "win32/signal.h" -# include <process.h> -#endif - #if HAVE_SYS_TIME_H # include <sys/time.h> #endif @@ -79,12 +71,6 @@ #include "fopen_wrappers.h" #include "ext/standard/php_standard.h" -#ifdef PHP_WIN32 -# include <io.h> -# include <fcntl.h> -# include "win32/php_registry.h" -#endif - #ifdef __riscos__ # include <unixlib/local.h> int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; @@ -109,21 +95,17 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS; #include "fpm_log.h" #include "zlog.h" -#ifndef PHP_WIN32 /* XXX this will need to change later when threaded fastcgi is implemented. shane */ struct sigaction act, old_term, old_quit, old_int; -#endif static void (*php_php_import_environment_variables)(zval *array_ptr); -#ifndef PHP_WIN32 /* these globals used for forking children on unix systems */ /** * Set to non-zero if we are the parent process */ static int parent = 1; -#endif static int request_body_fd; static int fpm_is_running = 0; @@ -206,19 +188,6 @@ static php_cgi_globals_struct php_cgi_globals; #define CGIG(v) (php_cgi_globals.v) #endif -#ifdef PHP_WIN32 -#define TRANSLATE_SLASHES(path) \ - { \ - char *tmp = path; \ - while (*tmp) { \ - if (*tmp == '\\') *tmp = '/'; \ - tmp++; \ - } \ - } -#else -#define TRANSLATE_SLASHES(path) -#endif - static int print_module_info(zval *zv) /* {{{ */ { zend_module_entry *module = Z_PTR_P(zv); @@ -332,11 +301,7 @@ static void sapi_cgibin_flush(void *server_context) /* {{{ */ /* fpm has started, let use fcgi instead of stdout */ if (fpm_is_running) { fcgi_request *request = (fcgi_request*) server_context; - if ( -#ifndef PHP_WIN32 - !parent && -#endif - request && !fcgi_flush(request, 0)) { + if (!parent && request && !fcgi_flush(request, 0)) { php_handle_aborted_connection(); } return; @@ -568,15 +533,15 @@ void cgi_php_import_environment_variables(zval *array_ptr) /* {{{ */ Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) && zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0 ) { - zval_dtor(array_ptr); - ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]); + zend_array_destroy(Z_ARR_P(array_ptr)); + Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_ENV])); return; } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) && zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0 ) { - zval_dtor(array_ptr); - ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]); + zend_array_destroy(Z_ARR_P(array_ptr)); + Z_ARR_P(array_ptr) = zend_array_dup(Z_ARR(PG(http_globals)[TRACK_VARS_SERVER])); return; } @@ -639,21 +604,15 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len) fcgi_request *request = (fcgi_request*) SG(server_context); - /* ensure we want: - * - to log (fastcgi.logging in php.ini) + /* message is written to FCGI_STDERR if following conditions are met: + * - logging is enabled (fastcgi.logging in php.ini) * - we are currently dealing with a request * - the message is not empty + * - the fcgi_write did not fail */ - if (CGIG(fcgi_logging) && request && message && len > 0) { - ssize_t ret; - char *buf = malloc(len + 2); - memcpy(buf, message, len); - memcpy(buf + len, "\n", sizeof("\n")); - ret = fcgi_write(request, FCGI_STDERR, buf, len + 1); - free(buf); - if (ret < 0) { - php_handle_aborted_connection(); - } + if (CGIG(fcgi_logging) && request && message && len > 0 + && fcgi_write(request, FCGI_STDERR, message, len) < 0) { + php_handle_aborted_connection(); } } /* }}} */ @@ -662,7 +621,7 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len) */ static void sapi_cgi_log_message(char *message, int syslog_type_int) { - zlog(ZLOG_NOTICE, "PHP message: %s", message); + zlog_msg(ZLOG_NOTICE, "PHP message: ", message); } /* }}} */ @@ -717,11 +676,7 @@ static void php_cgi_ini_activate_user_config(char *path, int path_len, const cha if it is inside the docroot, we scan the tree up to the docroot to find more user.ini, if not we only scan the current path. */ -#ifdef PHP_WIN32 - if (strnicmp(s1, s2, s_len) == 0) { -#else if (strncmp(s1, s2, s_len) == 0) { -#endif ptr = s2 + start; /* start is the point where doc_root ends! */ while ((ptr = strchr(ptr, DEFAULT_SLASH)) != NULL) { *ptr = 0; @@ -795,18 +750,11 @@ static int sapi_cgi_activate(void) /* {{{ */ if (doc_root_len > 0 && IS_SLASH(doc_root[doc_root_len - 1])) { --doc_root_len; } -#ifdef PHP_WIN32 - /* paths on windows should be case-insensitive */ - doc_root = estrndup(doc_root, doc_root_len); - zend_str_tolower(doc_root, doc_root_len); -#endif + php_cgi_ini_activate_user_config(path, path_len, doc_root, doc_root_len, doc_root_len - 1); } } -#ifdef PHP_WIN32 - efree(doc_root); -#endif efree(path); } @@ -821,11 +769,7 @@ static int sapi_cgi_deactivate(void) /* {{{ */ 2. When the first call occurs and the request is not set up, flush fails on FastCGI. */ if (SG(sapi_started)) { - if ( -#ifndef PHP_WIN32 - !parent && -#endif - !fcgi_finish_request((fcgi_request*)SG(server_context), 0)) { + if (!parent && !fcgi_finish_request((fcgi_request*)SG(server_context), 0)) { php_handle_aborted_connection(); } } @@ -1047,7 +991,7 @@ static void init_request_info(void) /* script_path_translated being set is a good indication that * we are running in a cgi environment, since it is always * null otherwise. otherwise, the filename - * of the script will be retreived later via argc/argv */ + * of the script will be retrieved later via argc/argv */ if (script_path_translated) { const char *auth; char *content_length = FCGI_GETENV(request, "CONTENT_LENGTH"); @@ -1137,8 +1081,6 @@ static void init_request_info(void) if (!env_document_root && PG(doc_root)) { env_document_root = FCGI_PUTENV(request, "DOCUMENT_ROOT", PG(doc_root)); - /* fix docroot */ - TRANSLATE_SLASHES(env_document_root); } if (!apache_was_here && env_path_translated != NULL && env_redirect_url != NULL && @@ -1171,9 +1113,6 @@ static void init_request_info(void) if (script_path_translated && (script_path_translated_len = strlen(script_path_translated)) > 0 && (script_path_translated[script_path_translated_len-1] == '/' || -#ifdef PHP_WIN32 - script_path_translated[script_path_translated_len-1] == '\\' || -#endif (real_path = tsrm_realpath(script_path_translated, NULL)) == NULL) ) { char *pt = estrndup(script_path_translated, script_path_translated_len); @@ -1251,7 +1190,6 @@ static void init_request_info(void) } script_path_translated = FCGI_PUTENV(request, "SCRIPT_FILENAME", pt); } - TRANSLATE_SLASHES(pt); /* figure out docroot * SCRIPT_FILENAME minus SCRIPT_NAME @@ -1529,10 +1467,17 @@ static PHP_MINFO_FUNCTION(cgi) } /* }}} */ +ZEND_BEGIN_ARG_INFO(cgi_fcgi_sapi_no_arginfo, 0) +ZEND_END_ARG_INFO() + PHP_FUNCTION(fastcgi_finish_request) /* {{{ */ { fcgi_request *request = (fcgi_request*) SG(server_context); + if (zend_parse_parameters_none() == FAILURE) { + return; + } + if (!fcgi_is_closed(request)) { php_output_end_all(); php_header(); @@ -1547,8 +1492,39 @@ PHP_FUNCTION(fastcgi_finish_request) /* {{{ */ } /* }}} */ +PHP_FUNCTION(apache_request_headers) /* {{{ */ +{ + fcgi_request *request; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + array_init(return_value); + if ((request = (fcgi_request*) SG(server_context))) { + fcgi_loadenv(request, sapi_add_request_header, return_value); + } +} /* }}} */ + +/* {{{ proto array fpm_get_status + * Returns the status of the fastcgi process manager */ +PHP_FUNCTION(fpm_get_status) /* {{{ */ +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + if (fpm_status_export_to_zval(return_value)) { + RETURN_FALSE; + } +} +/* }}} */ + static const zend_function_entry cgi_fcgi_sapi_functions[] = { - PHP_FE(fastcgi_finish_request, NULL) + PHP_FE(fastcgi_finish_request, cgi_fcgi_sapi_no_arginfo) + PHP_FE(fpm_get_status, cgi_fcgi_sapi_no_arginfo) + PHP_FE(apache_request_headers, cgi_fcgi_sapi_no_arginfo) + PHP_FALIAS(getallheaders, apache_request_headers, cgi_fcgi_sapi_no_arginfo) PHP_FE_END }; @@ -1583,7 +1559,7 @@ int main(int argc, char *argv[]) void ***tsrm_ls; #endif - int max_requests = 500; + int max_requests = 0; int requests = 0; int fcgi_fd = 0; fcgi_request *request; @@ -1595,6 +1571,10 @@ int main(int argc, char *argv[]) int force_stderr = 0; int php_information = 0; int php_allow_to_run_as_root = 0; + int ret; +#if ZEND_RC_DEBUG + zend_bool old_rc_debug; +#endif #ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) @@ -1624,13 +1604,6 @@ int main(int argc, char *argv[]) fcgi_init(); -#ifdef PHP_WIN32 - _fmode = _O_BINARY; /* sets default for file streams to binary */ - setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ -#endif - while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (c) { case 'c': @@ -1858,7 +1831,18 @@ consult the installation file that came with this distribution, or visit \n\ } } - if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root, force_daemon, force_stderr)) { +#if ZEND_RC_DEBUG + old_rc_debug = zend_rc_debug; + zend_rc_debug = 0; +#endif + + ret = fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root, force_daemon, force_stderr); + +#if ZEND_RC_DEBUG + zend_rc_debug = old_rc_debug; +#endif + + if (ret < 0) { if (fpm_globals.send_config_pipe[1]) { int writeval = 0; @@ -2027,10 +2011,6 @@ out: tsrm_shutdown(); #endif -#if defined(PHP_WIN32) && ZEND_DEBUG && 0 - _CrtDumpMemoryLeaks(); -#endif - return exit_status; } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index dc81b702ce..ab3c5af18e 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -1,4 +1,3 @@ - /* $Id: fpm_php.c,v 1.22.2.4 2008/12/13 03:21:18 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -42,7 +41,7 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_ ini_entry->modifiable = mode; } } else { - zend_string_release(duplicate); + zend_string_release_ex(duplicate, 1); } return SUCCESS; diff --git a/sapi/fpm/fpm/fpm_php.h b/sapi/fpm/fpm/fpm_php.h index d0577e22f3..978f3209d5 100644 --- a/sapi/fpm/fpm/fpm_php.h +++ b/sapi/fpm/fpm/fpm_php.h @@ -1,4 +1,3 @@ - /* $Id: fpm_php.h,v 1.10.2.1 2008/11/15 00:57:24 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_PHP_H diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c index 7480bd7648..3174eef2fb 100644 --- a/sapi/fpm/fpm/fpm_php_trace.c +++ b/sapi/fpm/fpm/fpm_php_trace.c @@ -1,4 +1,3 @@ - /* $Id: fpm_php_trace.c,v 1.27.2.1 2008/11/15 00:57:24 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_php_trace.h b/sapi/fpm/fpm/fpm_php_trace.h index 3d9c81e472..6a83cff127 100644 --- a/sapi/fpm/fpm/fpm_php_trace.h +++ b/sapi/fpm/fpm/fpm_php_trace.h @@ -1,4 +1,3 @@ - /* $Id: fpm_php_trace.h,v 1.2 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_PHP_TRACE_H diff --git a/sapi/fpm/fpm/fpm_process_ctl.c b/sapi/fpm/fpm/fpm_process_ctl.c index f99ec241c7..17fbe8d3e0 100644 --- a/sapi/fpm/fpm/fpm_process_ctl.c +++ b/sapi/fpm/fpm/fpm_process_ctl.c @@ -1,4 +1,3 @@ - /* $Id: fpm_process_ctl.c,v 1.19.2.2 2008/12/13 03:21:18 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -293,13 +292,14 @@ static void fpm_pctl_check_request_timeout(struct timeval *now) /* {{{ */ struct fpm_worker_pool_s *wp; for (wp = fpm_worker_all_pools; wp; wp = wp->next) { + int track_finished = wp->config->request_terminate_timeout_track_finished; int terminate_timeout = wp->config->request_terminate_timeout; int slowlog_timeout = wp->config->request_slowlog_timeout; struct fpm_child_s *child; if (terminate_timeout || slowlog_timeout) { for (child = wp->children; child; child = child->next) { - fpm_request_check_timed_out(child, now, terminate_timeout, slowlog_timeout); + fpm_request_check_timed_out(child, now, terminate_timeout, slowlog_timeout, track_finished); } } } diff --git a/sapi/fpm/fpm/fpm_process_ctl.h b/sapi/fpm/fpm/fpm_process_ctl.h index 8888f738a0..f39a489f61 100644 --- a/sapi/fpm/fpm/fpm_process_ctl.h +++ b/sapi/fpm/fpm/fpm_process_ctl.h @@ -1,4 +1,3 @@ - /* $Id: fpm_process_ctl.h,v 1.6 2008/07/20 21:33:10 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_PROCESS_CTL_H diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c index a4ace85310..83401f1553 100644 --- a/sapi/fpm/fpm/fpm_request.c +++ b/sapi/fpm/fpm/fpm_request.c @@ -1,4 +1,3 @@ - /* $Id: fpm_request.c,v 1.9.2.1 2008/11/15 00:57:24 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifdef HAVE_TIMES #include <sys/times.h> @@ -17,6 +16,7 @@ #include "fpm_children.h" #include "fpm_scoreboard.h" #include "fpm_status.h" +#include "fpm_stdio.h" #include "fpm_request.h" #include "fpm_log.h" @@ -200,6 +200,7 @@ void fpm_request_end(void) /* {{{ */ #endif proc->memory = memory; fpm_scoreboard_proc_release(proc); + fpm_stdio_flush_child(); } /* }}} */ @@ -222,7 +223,7 @@ void fpm_request_finished() /* {{{ */ } /* }}} */ -void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, int terminate_timeout, int slowlog_timeout) /* {{{ */ +void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, int terminate_timeout, int slowlog_timeout, int track_finished) /* {{{ */ { struct fpm_scoreboard_proc_s proc, *proc_p; @@ -244,7 +245,7 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, } #endif - if (proc.request_stage > FPM_REQUEST_ACCEPTING && proc.request_stage < FPM_REQUEST_END) { + if (proc.request_stage > FPM_REQUEST_ACCEPTING && ((proc.request_stage < FPM_REQUEST_END) || track_finished)) { char purified_script_filename[sizeof(proc.script_filename)]; struct timeval tv; diff --git a/sapi/fpm/fpm/fpm_request.h b/sapi/fpm/fpm/fpm_request.h index 1328b5de4e..15bce58e4b 100644 --- a/sapi/fpm/fpm/fpm_request.h +++ b/sapi/fpm/fpm/fpm_request.h @@ -1,4 +1,3 @@ - /* $Id: fpm_request.h,v 1.4 2008/07/20 01:47:16 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_REQUEST_H @@ -14,7 +13,7 @@ void fpm_request_finished(); /* request processed: cleaning current request * struct fpm_child_s; struct timeval; -void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *tv, int terminate_timeout, int slowlog_timeout); +void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *tv, int terminate_timeout, int slowlog_timeout, int track_finished); int fpm_request_is_idle(struct fpm_child_s *child); const char *fpm_request_get_stage_name(int stage); int fpm_request_last_activity(struct fpm_child_s *child, struct timeval *tv); diff --git a/sapi/fpm/fpm/fpm_scoreboard.c b/sapi/fpm/fpm/fpm_scoreboard.c index 7a65fcbeb7..328f999f0c 100644 --- a/sapi/fpm/fpm/fpm_scoreboard.c +++ b/sapi/fpm/fpm/fpm_scoreboard.c @@ -1,4 +1,3 @@ - /* $Id: fpm_status.c 312399 2011-06-23 08:03:52Z fat $ */ /* (c) 2009 Jerome Loyet */ #include "php.h" diff --git a/sapi/fpm/fpm/fpm_scoreboard.h b/sapi/fpm/fpm/fpm_scoreboard.h index abce616d76..1fecde1d0f 100644 --- a/sapi/fpm/fpm/fpm_scoreboard.h +++ b/sapi/fpm/fpm/fpm_scoreboard.h @@ -1,4 +1,3 @@ - /* $Id: fpm_status.h 312263 2011-06-18 17:46:16Z felipe $ */ /* (c) 2009 Jerome Loyet */ #ifndef FPM_SCOREBOARD_H diff --git a/sapi/fpm/fpm/fpm_shm.c b/sapi/fpm/fpm/fpm_shm.c index 9a58e9d006..52ae60ed28 100644 --- a/sapi/fpm/fpm/fpm_shm.c +++ b/sapi/fpm/fpm/fpm_shm.c @@ -1,4 +1,3 @@ - /* $Id: fpm_shm.c,v 1.3 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin, Jerome Loyet */ #include <sys/mman.h> diff --git a/sapi/fpm/fpm/fpm_shm.h b/sapi/fpm/fpm/fpm_shm.h index c9bfb4ee72..4382aac29b 100644 --- a/sapi/fpm/fpm/fpm_shm.h +++ b/sapi/fpm/fpm/fpm_shm.h @@ -1,4 +1,3 @@ - /* $Id: fpm_shm.h,v 1.3 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_SHM_H diff --git a/sapi/fpm/fpm/fpm_signals.c b/sapi/fpm/fpm/fpm_signals.c index 4c9f9664f6..caf41e8a3f 100644 --- a/sapi/fpm/fpm/fpm_signals.c +++ b/sapi/fpm/fpm/fpm_signals.c @@ -1,4 +1,3 @@ - /* $Id: fpm_signals.c,v 1.24 2008/08/26 15:09:15 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_signals.h b/sapi/fpm/fpm/fpm_signals.h index 759a4e316c..7202816218 100644 --- a/sapi/fpm/fpm/fpm_signals.h +++ b/sapi/fpm/fpm/fpm_signals.h @@ -1,4 +1,3 @@ - /* $Id: fpm_signals.h,v 1.5 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_SIGNALS_H diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index 727e2eb132..aaa16cc89e 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -1,4 +1,3 @@ - /* $Id: fpm_sockets.c,v 1.20.2.1 2008/12/13 03:21:18 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -201,7 +200,7 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct if (wp->listen_address_domain == FPM_AF_UNIX) { if (fpm_socket_unix_test_connect((struct sockaddr_un *)sa, socklen) == 0) { - zlog(ZLOG_ERROR, "An another FPM instance seems to already listen on %s", ((struct sockaddr_un *) sa)->sun_path); + zlog(ZLOG_ERROR, "Another FPM instance seems to already listen on %s", ((struct sockaddr_un *) sa)->sun_path); close(sock); return -1; } diff --git a/sapi/fpm/fpm/fpm_sockets.h b/sapi/fpm/fpm/fpm_sockets.h index 020bb50134..9d899c0757 100644 --- a/sapi/fpm/fpm/fpm_sockets.h +++ b/sapi/fpm/fpm/fpm_sockets.h @@ -1,4 +1,3 @@ - /* $Id: fpm_sockets.h,v 1.12 2008/08/26 15:09:15 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_MISC_H diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 1d78ebf849..36d2240635 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -1,7 +1,7 @@ - /* $Id$ */ /* (c) 2009 Jerome Loyet */ #include "php.h" +#include "zend_long.h" #include "SAPI.h" #include <stdio.h> @@ -9,7 +9,6 @@ #include "fpm_scoreboard.h" #include "fpm_status.h" #include "fpm_clock.h" -#include "fpm_scoreboard.h" #include "zlog.h" #include "fpm_atomic.h" #include "fpm_conf.h" @@ -45,6 +44,103 @@ int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ } /* }}} */ +int fpm_status_export_to_zval(zval *status) +{ + struct fpm_scoreboard_s scoreboard, *scoreboard_p; + zval fpm_proc_stats, fpm_proc_stat; + time_t now_epoch; + struct timeval duration, now; + double cpu; + int i; + + + scoreboard_p = fpm_scoreboard_acquire(NULL, 1); + if (!scoreboard_p) { + zlog(ZLOG_NOTICE, "[pool %s] status: scoreboard already in use.", scoreboard_p->pool); + return -1; + } + + /* copy the scoreboard not to bother other processes */ + scoreboard = *scoreboard_p; + struct fpm_scoreboard_proc_s procs[scoreboard.nprocs]; + + struct fpm_scoreboard_proc_s *proc_p; + for(i=0; i<scoreboard.nprocs; i++) { + proc_p = fpm_scoreboard_proc_acquire(scoreboard_p, i, 1); + if (!proc_p){ + procs[i].used=-1; + continue; + } + procs[i] = *proc_p; + fpm_scoreboard_proc_release(proc_p); + } + fpm_scoreboard_release(scoreboard_p); + + now_epoch = time(NULL); + fpm_clock_get(&now); + + array_init(status); + add_assoc_string(status, "pool", scoreboard.pool); + add_assoc_string(status, "process-manager", PM2STR(scoreboard.pm)); + add_assoc_long(status, "start-time", scoreboard.start_epoch); + add_assoc_long(status, "start-since", now_epoch - scoreboard.start_epoch); + add_assoc_long(status, "accepted-conn", scoreboard.requests); +#ifdef HAVE_FPM_LQ + add_assoc_long(status, "listen-queue", scoreboard.lq); + add_assoc_long(status, "max-listen-queue", scoreboard.lq_max); + add_assoc_long(status, "listen-queue-len", scoreboard.lq_len); +#endif + add_assoc_long(status, "idle-processes", scoreboard.idle); + add_assoc_long(status, "active-processes", scoreboard.active); + add_assoc_long(status, "total-processes", scoreboard.idle + scoreboard.active); + add_assoc_long(status, "max-active-processes", scoreboard.active_max); + add_assoc_long(status, "max-children-reached", scoreboard.max_children_reached); + add_assoc_long(status, "slow-requests", scoreboard.slow_rq); + + array_init(&fpm_proc_stats); + for(i=0; i<scoreboard.nprocs; i++) { + if (!procs[i].used) { + continue; + } + proc_p = &procs[i]; +#ifdef HAVE_FPM_LQ + /* prevent NaN */ + if (procs[i].cpu_duration.tv_sec == 0 && procs[i].cpu_duration.tv_usec == 0) { + cpu = 0.; + } else { + cpu = (procs[i].last_request_cpu.tms_utime + procs[i].last_request_cpu.tms_stime + procs[i].last_request_cpu.tms_cutime + procs[i].last_request_cpu.tms_cstime) / fpm_scoreboard_get_tick() / (procs[i].cpu_duration.tv_sec + procs[i].cpu_duration.tv_usec / 1000000.) * 100.; + } +#endif + + array_init(&fpm_proc_stat); + add_assoc_long(&fpm_proc_stat, "pid", procs[i].pid); + add_assoc_string(&fpm_proc_stat, "state", fpm_request_get_stage_name(procs[i].request_stage)); + add_assoc_long(&fpm_proc_stat, "start-time", procs[i].start_epoch); + add_assoc_long(&fpm_proc_stat, "start-since", now_epoch - procs[i].start_epoch); + add_assoc_long(&fpm_proc_stat, "requests", procs[i].requests); + if (procs[i].request_stage == FPM_REQUEST_ACCEPTING) { + duration = procs[i].duration; + } else { + timersub(&now, &procs[i].accepted, &duration); + } + add_assoc_long(&fpm_proc_stat, "request-duration", duration.tv_sec * 1000000UL + duration.tv_usec); + add_assoc_string(&fpm_proc_stat, "request-method", procs[i].request_method[0] != '\0' ? procs[i].request_method : "-"); + add_assoc_string(&fpm_proc_stat, "request-uri", procs[i].request_uri); + add_assoc_string(&fpm_proc_stat, "query-string", procs[i].query_string); + add_assoc_long(&fpm_proc_stat, "request-length", procs[i].content_length); + add_assoc_string(&fpm_proc_stat, "user", procs[i].auth_user[0] != '\0' ? procs[i].auth_user : "-"); + add_assoc_string(&fpm_proc_stat, "script", procs[i].script_filename[0] != '\0' ? procs[i].script_filename : "-"); +#ifdef HAVE_FPM_LQ + add_assoc_double(&fpm_proc_stat, "last-request-cpu", procs[i].request_stage == FPM_REQUEST_ACCEPTING ? cpu : 0.); +#endif + add_assoc_long(&fpm_proc_stat, "last-request-memory", procs[i].request_stage == FPM_REQUEST_ACCEPTING ? procs[i].memory : 0); + add_next_index_zval(&fpm_proc_stats, &fpm_proc_stat); + } + add_assoc_zval(status, "procs", &fpm_proc_stats); + return 0; +} +/* }}} */ + int fpm_status_handle_request(void) /* {{{ */ { struct fpm_scoreboard_s scoreboard, *scoreboard_p; @@ -150,9 +246,9 @@ int fpm_status_handle_request(void) /* {{{ */ "<tr><th>start since</th><td>%lu</td></tr>\n" "<tr><th>accepted conn</th><td>%lu</td></tr>\n" #ifdef HAVE_FPM_LQ - "<tr><th>listen queue</th><td>%u</td></tr>\n" - "<tr><th>max listen queue</th><td>%u</td></tr>\n" - "<tr><th>listen queue len</th><td>%d</td></tr>\n" + "<tr><th>listen queue</th><td>%d</td></tr>\n" + "<tr><th>max listen queue</th><td>%d</td></tr>\n" + "<tr><th>listen queue len</th><td>%u</td></tr>\n" #endif "<tr><th>idle processes</th><td>%d</td></tr>\n" "<tr><th>active processes</th><td>%d</td></tr>\n" @@ -222,9 +318,9 @@ int fpm_status_handle_request(void) /* {{{ */ "<start-since>%lu</start-since>\n" "<accepted-conn>%lu</accepted-conn>\n" #ifdef HAVE_FPM_LQ - "<listen-queue>%u</listen-queue>\n" - "<max-listen-queue>%u</max-listen-queue>\n" - "<listen-queue-len>%d</listen-queue-len>\n" + "<listen-queue>%d</listen-queue>\n" + "<max-listen-queue>%d</max-listen-queue>\n" + "<listen-queue-len>%u</listen-queue-len>\n" #endif "<idle-processes>%d</idle-processes>\n" "<active-processes>%d</active-processes>\n" @@ -272,9 +368,9 @@ int fpm_status_handle_request(void) /* {{{ */ "\"start since\":%lu," "\"accepted conn\":%lu," #ifdef HAVE_FPM_LQ - "\"listen queue\":%u," - "\"max listen queue\":%u," - "\"listen queue len\":%d," + "\"listen queue\":%d," + "\"max listen queue\":%d," + "\"listen queue len\":%u," #endif "\"idle processes\":%d," "\"active processes\":%d," @@ -322,9 +418,9 @@ int fpm_status_handle_request(void) /* {{{ */ "start since: %lu\n" "accepted conn: %lu\n" #ifdef HAVE_FPM_LQ - "listen queue: %u\n" - "max listen queue: %u\n" - "listen queue len: %d\n" + "listen queue: %d\n" + "max listen queue: %d\n" + "listen queue len: %u\n" #endif "idle processes: %d\n" "active processes: %d\n" @@ -361,7 +457,7 @@ int fpm_status_handle_request(void) /* {{{ */ scoreboard.pool, PM2STR(scoreboard.pm), time_buffer, - now_epoch - scoreboard.start_epoch, + (unsigned long) (now_epoch - scoreboard.start_epoch), scoreboard.requests, #ifdef HAVE_FPM_LQ scoreboard.lq, @@ -377,7 +473,7 @@ int fpm_status_handle_request(void) /* {{{ */ PUTS(buffer); efree(buffer); - zend_string_release(_GET_str); + zend_string_release_ex(_GET_str, 0); if (short_post) { PUTS(short_post); @@ -442,10 +538,10 @@ int fpm_status_handle_request(void) /* {{{ */ } strftime(time_buffer, sizeof(time_buffer) - 1, time_format, localtime(&proc.start_epoch)); spprintf(&buffer, 0, full_syntax, - proc.pid, + (int) proc.pid, fpm_request_get_stage_name(proc.request_stage), time_buffer, - now_epoch - proc.start_epoch, + (unsigned long) (now_epoch - proc.start_epoch), proc.requests, duration.tv_sec * 1000000UL + duration.tv_usec, proc.request_method[0] != '\0' ? proc.request_method : "-", diff --git a/sapi/fpm/fpm/fpm_status.h b/sapi/fpm/fpm/fpm_status.h index 37b2eed8f9..bc90c6a9df 100644 --- a/sapi/fpm/fpm/fpm_status.h +++ b/sapi/fpm/fpm/fpm_status.h @@ -1,4 +1,3 @@ - /* $Id$ */ /* (c) 2009 Jerome Loyet */ #ifndef FPM_STATUS_H @@ -27,6 +26,7 @@ void fpm_status_increment_accepted_conn(struct fpm_shm_s *shm); void fpm_status_set_pm(struct fpm_shm_s *shm, int pm); void fpm_status_update_max_children_reached(struct fpm_shm_s *shm, unsigned int max_children_reached); void fpm_status_increment_max_children_reached(struct fpm_shm_s *shm); +int fpm_status_export_to_zval(zval *status); int fpm_status_handle_request(void); extern struct fpm_shm_s *fpm_status_shm; diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c index 7abd5b43a2..fde9c9144c 100644 --- a/sapi/fpm/fpm/fpm_stdio.c +++ b/sapi/fpm/fpm/fpm_stdio.c @@ -1,4 +1,3 @@ - /* $Id: fpm_stdio.c,v 1.22.2.2 2008/12/13 03:32:24 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -14,6 +13,7 @@ #include "fpm.h" #include "fpm_children.h" +#include "fpm_cleanup.h" #include "fpm_events.h" #include "fpm_sockets.h" #include "fpm_stdio.h" @@ -106,6 +106,12 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ } /* }}} */ +int fpm_stdio_flush_child() /* {{{ */ +{ + return write(STDERR_FILENO, "\0", 1); +} +/* }}} */ + static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) /* {{{ */ { static const int max_buf_size = 1024; @@ -115,14 +121,16 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) int is_stdout; struct fpm_event_s *event; int fifo_in = 1, fifo_out = 1; - int is_last_message = 0; int in_buf = 0; + int read_fail = 0, finish_log_stream = 0, create_log_stream; int res; + struct zlog_stream *log_stream; if (!arg) { return; } child = (struct fpm_child_s *)arg; + is_stdout = (fd == child->fd_stdout); if (is_stdout) { event = &child->ev_stdout; @@ -130,32 +138,46 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) event = &child->ev_stderr; } + create_log_stream = !child->log_stream; + if (create_log_stream) { + log_stream = child->log_stream = malloc(sizeof(struct zlog_stream)); + zlog_stream_init_ex(log_stream, ZLOG_WARNING, STDERR_FILENO); + zlog_stream_set_decorating(log_stream, child->wp->config->decorate_workers_output); + zlog_stream_set_wrapping(log_stream, ZLOG_TRUE); + zlog_stream_set_msg_prefix(log_stream, STREAM_SET_MSG_PREFIX_FMT, + child->wp->config->name, (int) child->pid, is_stdout ? "stdout" : "stderr"); + zlog_stream_set_msg_quoting(log_stream, ZLOG_TRUE); + zlog_stream_set_is_stdout(log_stream, is_stdout); + zlog_stream_set_child_pid(log_stream, (int)child->pid); + } else { + log_stream = child->log_stream; + // if fd type (stdout/stderr) or child's pid is changed, + // then the stream will be finished and msg's prefix will be reinitialized + if (log_stream->is_stdout != (unsigned int)is_stdout || log_stream->child_pid != (int)child->pid) { + zlog_stream_finish(log_stream); + zlog_stream_set_msg_prefix(log_stream, STREAM_SET_MSG_PREFIX_FMT, + child->wp->config->name, (int) child->pid, is_stdout ? "stdout" : "stderr"); + zlog_stream_set_is_stdout(log_stream, is_stdout); + zlog_stream_set_child_pid(log_stream, (int)child->pid); + } + } + while (fifo_in || fifo_out) { if (fifo_in) { res = read(fd, buf + in_buf, max_buf_size - 1 - in_buf); if (res <= 0) { /* no data */ fifo_in = 0; - if (res < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) { - /* just no more data ready */ - } else { /* error or pipe is closed */ - - if (res < 0) { /* error */ - zlog(ZLOG_SYSERROR, "unable to read what child say"); - } - - fpm_event_del(event); - is_last_message = 1; - - if (is_stdout) { - close(child->fd_stdout); - child->fd_stdout = -1; - } else { - close(child->fd_stderr); - child->fd_stderr = -1; - } + if (res == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) { + /* pipe is closed or error */ + read_fail = (res < 0) ? res : 1; } } else { in_buf += res; + /* if buffer ends with \0, then the stream will be finished */ + if (!buf[in_buf - 1]) { + finish_log_stream = 1; + in_buf--; + } } } @@ -164,41 +186,47 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) fifo_out = 0; } else { char *nl; - int should_print = 0; - buf[in_buf] = '\0'; - - /* FIXME: there might be binary data */ - /* we should print if no more space in the buffer */ - if (in_buf == max_buf_size - 1) { - should_print = 1; + nl = memchr(buf, '\n', in_buf); + if (nl) { + /* we should print each new line int the new message */ + int out_len = nl - buf; + zlog_stream_str(log_stream, buf, out_len); + zlog_stream_finish(log_stream); + /* skip new line */ + out_len++; + /* move data in the buffer */ + memmove(buf, buf + out_len, in_buf - out_len); + in_buf -= out_len; + } else if (in_buf == max_buf_size - 1 || !fifo_in) { + /* we should print if no more space in the buffer or no more data to come */ + zlog_stream_str(log_stream, buf, in_buf); + in_buf = 0; } + } + } + } - /* we should print if no more data to come */ - if (!fifo_in) { - should_print = 1; - } - - nl = strchr(buf, '\n'); - if (nl || should_print) { - - if (nl) { - *nl = '\0'; - } + if (read_fail) { + if (create_log_stream) { + zlog_stream_set_msg_suffix(log_stream, NULL, ", pipe is closed"); + zlog_stream_finish(log_stream); + } + if (read_fail < 0) { + zlog(ZLOG_SYSERROR, "unable to read what child say"); + } - zlog(ZLOG_WARNING, "[pool %s] child %d said into %s: \"%s\"%s", child->wp->config->name, - (int) child->pid, is_stdout ? "stdout" : "stderr", buf, is_last_message ? ", pipe is closed" : ""); + fpm_event_del(event); - if (nl) { - int out_buf = 1 + nl - buf; - memmove(buf, buf + out_buf, in_buf - out_buf); - in_buf -= out_buf; - } else { - in_buf = 0; - } - } - } + if (is_stdout) { + close(child->fd_stdout); + child->fd_stdout = -1; + } else { + close(child->fd_stderr); + child->fd_stderr = -1; } + } else if (finish_log_stream) { + zlog_stream_finish(log_stream); } } /* }}} */ @@ -289,7 +317,7 @@ int fpm_stdio_open_error_log(int reopen) /* {{{ */ #ifdef HAVE_SYSLOG_H if (!strcasecmp(fpm_global_config.error_log, "syslog")) { - openlog(fpm_global_config.syslog_ident, LOG_PID | LOG_CONS, fpm_global_config.syslog_facility); + php_openlog(fpm_global_config.syslog_ident, LOG_PID | LOG_CONS, fpm_global_config.syslog_facility); fpm_globals.error_log_fd = ZLOG_SYSLOG; if (fpm_use_error_log()) { zlog_set_fd(fpm_globals.error_log_fd); diff --git a/sapi/fpm/fpm/fpm_stdio.h b/sapi/fpm/fpm/fpm_stdio.h index f5c45e1f6f..ef96508459 100644 --- a/sapi/fpm/fpm/fpm_stdio.h +++ b/sapi/fpm/fpm/fpm_stdio.h @@ -1,4 +1,3 @@ - /* $Id: fpm_stdio.h,v 1.9 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_STDIO_H @@ -6,9 +5,12 @@ #include "fpm_worker_pool.h" +#define STREAM_SET_MSG_PREFIX_FMT "[pool %s] child %d said into %s: " + int fpm_stdio_init_main(); int fpm_stdio_init_final(); int fpm_stdio_init_child(struct fpm_worker_pool_s *wp); +int fpm_stdio_flush_child(); int fpm_stdio_prepare_pipes(struct fpm_child_s *child); void fpm_stdio_child_use_pipes(struct fpm_child_s *child); int fpm_stdio_parent_use_pipes(struct fpm_child_s *child); diff --git a/sapi/fpm/fpm/fpm_str.h b/sapi/fpm/fpm/fpm_str.h index 90250ffe3c..efd05507c4 100644 --- a/sapi/fpm/fpm/fpm_str.h +++ b/sapi/fpm/fpm/fpm_str.h @@ -1,4 +1,3 @@ - /* $Id: fpm_str.h,v 1.3 2008/05/24 17:38:47 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_STR_H diff --git a/sapi/fpm/fpm/fpm_trace.c b/sapi/fpm/fpm/fpm_trace.c index 6fc24d544d..3d0b9de98a 100644 --- a/sapi/fpm/fpm/fpm_trace.c +++ b/sapi/fpm/fpm/fpm_trace.c @@ -1,4 +1,3 @@ - /* $Id: fpm_trace.c,v 1.1 2008/07/20 20:59:00 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_trace.h b/sapi/fpm/fpm/fpm_trace.h index 94cfafe213..4ee021229d 100644 --- a/sapi/fpm/fpm/fpm_trace.h +++ b/sapi/fpm/fpm/fpm_trace.h @@ -1,4 +1,3 @@ - /* $Id: fpm_trace.h,v 1.3 2008/07/20 22:43:39 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_TRACE_H diff --git a/sapi/fpm/fpm/fpm_trace_mach.c b/sapi/fpm/fpm/fpm_trace_mach.c index ee4e33469e..1ecee23d26 100644 --- a/sapi/fpm/fpm/fpm_trace_mach.c +++ b/sapi/fpm/fpm/fpm_trace_mach.c @@ -1,4 +1,3 @@ - /* $Id: fpm_trace_mach.c,v 1.4 2008/08/26 15:09:15 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_trace_pread.c b/sapi/fpm/fpm/fpm_trace_pread.c index 2f1fb5618f..604882eff3 100644 --- a/sapi/fpm/fpm/fpm_trace_pread.c +++ b/sapi/fpm/fpm/fpm_trace_pread.c @@ -1,4 +1,3 @@ - /* $Id: fpm_trace_pread.c,v 1.7 2008/08/26 15:09:15 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #define _GNU_SOURCE diff --git a/sapi/fpm/fpm/fpm_trace_ptrace.c b/sapi/fpm/fpm/fpm_trace_ptrace.c index 37d340bbc3..a2a3d25e30 100644 --- a/sapi/fpm/fpm/fpm_trace_ptrace.c +++ b/sapi/fpm/fpm/fpm_trace_ptrace.c @@ -1,4 +1,3 @@ - /* $Id: fpm_trace_ptrace.c,v 1.7 2008/09/18 23:34:11 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c index 1539c07ba2..6490a7b5ba 100644 --- a/sapi/fpm/fpm/fpm_unix.c +++ b/sapi/fpm/fpm/fpm_unix.c @@ -1,4 +1,3 @@ - /* $Id: fpm_unix.c,v 1.25.2.1 2008/12/13 03:18:23 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" @@ -535,7 +534,7 @@ int fpm_unix_init_main() /* {{{ */ exit(FPM_EXIT_SOFTWARE); } else { if (readval == 1) { - zlog(ZLOG_DEBUG, "I received a valid acknoledge from the master process, I can exit without error"); + zlog(ZLOG_DEBUG, "I received a valid acknowledge from the master process, I can exit without error"); fpm_cleanups_run(FPM_CLEANUP_PARENT_EXIT); exit(FPM_EXIT_OK); } else { diff --git a/sapi/fpm/fpm/fpm_unix.h b/sapi/fpm/fpm/fpm_unix.h index 1e30fc09c3..c65791f7ed 100644 --- a/sapi/fpm/fpm/fpm_unix.h +++ b/sapi/fpm/fpm/fpm_unix.h @@ -1,4 +1,3 @@ - /* $Id: fpm_unix.h,v 1.8 2008/05/25 13:21:13 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_UNIX_H diff --git a/sapi/fpm/fpm/fpm_worker_pool.c b/sapi/fpm/fpm/fpm_worker_pool.c index 90e155975e..e4ad73169d 100644 --- a/sapi/fpm/fpm/fpm_worker_pool.c +++ b/sapi/fpm/fpm/fpm_worker_pool.c @@ -1,4 +1,3 @@ - /* $Id: fpm_worker_pool.c,v 1.15.2.1 2008/12/13 03:21:18 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #include "fpm_config.h" diff --git a/sapi/fpm/fpm/fpm_worker_pool.h b/sapi/fpm/fpm/fpm_worker_pool.h index 68179d283d..37f4e51994 100644 --- a/sapi/fpm/fpm/fpm_worker_pool.h +++ b/sapi/fpm/fpm/fpm_worker_pool.h @@ -1,4 +1,3 @@ - /* $Id: fpm_worker_pool.h,v 1.13 2008/08/26 15:09:15 anight Exp $ */ /* (c) 2007,2008 Andrei Nigmatulin */ #ifndef FPM_WORKER_POOL_H diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c index 27ab6e4d14..ddfed2aef9 100644 --- a/sapi/fpm/fpm/zlog.c +++ b/sapi/fpm/fpm/zlog.c @@ -1,4 +1,3 @@ - /* $Id: zlog.c,v 1.7 2008/05/22 21:08:32 anight Exp $ */ /* (c) 2004-2007 Andrei Nigmatulin */ #include "fpm_config.h" @@ -17,10 +16,18 @@ #include "fpm.h" #include "zend_portability.h" -#define MAX_LINE_LENGTH 1024 +/* buffer is used for fmt result and it should never be over 2048 */ +#define MAX_BUF_LENGTH 2048 + +/* maximal length for wrapping prefix */ +#define MAX_WRAPPING_PREFIX_LENGTH 512 + +#define EXTRA_SPACE_FOR_PREFIX 128 static int zlog_fd = -1; static int zlog_level = ZLOG_NOTICE; +static int zlog_limit = ZLOG_DEFAULT_LIMIT; +static zlog_bool zlog_buffering = ZLOG_DEFAULT_BUFFERING; static int launched = 0; static void (*external_logger)(int, char *, size_t) = NULL; @@ -60,16 +67,19 @@ const char *zlog_get_level_name(int log_level) /* {{{ */ } /* }}} */ -void zlog_set_launched(void) { +void zlog_set_launched(void) /* {{{ */ +{ launched = 1; } +/* }}} */ size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len) /* {{{ */ { struct tm t; size_t len; - len = strftime(timebuf, timebuf_len, "[%d-%b-%Y %H:%M:%S", localtime_r((const time_t *) &tv->tv_sec, &t)); + len = strftime(timebuf, timebuf_len, "[%d-%b-%Y %H:%M:%S", + localtime_r((const time_t *) &tv->tv_sec, &t)); if (zlog_level == ZLOG_DEBUG) { len += snprintf(timebuf + len, timebuf_len - len, ".%06d", (int) tv->tv_usec); } @@ -98,39 +108,60 @@ int zlog_set_level(int new_value) /* {{{ */ } /* }}} */ -void vzlog(const char *function, int line, int flags, const char *fmt, va_list args) /* {{{ */ +int zlog_set_limit(int new_value) /* {{{ */ { - struct timeval tv; - char buf[MAX_LINE_LENGTH]; - const size_t buf_size = MAX_LINE_LENGTH; - size_t len = 0; - int truncated = 0; - int saved_errno; + int old_value = zlog_limit; - if (external_logger) { - va_list ap; - va_copy(ap, args); - len = vsnprintf(buf, buf_size, fmt, ap); - va_end(ap); - if (len >= buf_size) { - memcpy(buf + buf_size - sizeof("..."), "...", sizeof("...") - 1); - len = buf_size - 1; - } - external_logger(flags & ZLOG_LEVEL_MASK, buf, len); - len = 0; - memset(buf, '\0', buf_size); - } + zlog_limit = new_value; + return old_value; +} +/* }}} */ - if ((flags & ZLOG_LEVEL_MASK) < zlog_level) { - return; +int zlog_set_buffering(zlog_bool buffering) /* {{{ */ +{ + int old_value = zlog_buffering; + + zlog_buffering = buffering; + return old_value; +} +/* }}} */ + +static inline size_t zlog_truncate_buf(char *buf, size_t buf_size, size_t space_left) /* {{{ */ +{ + memcpy(buf + buf_size - sizeof("...") + 1 - space_left, "...", sizeof("...") - 1); + return buf_size - space_left; +} +/* }}} */ + +static inline void zlog_external( + int flags, char *buf, size_t buf_size, const char *fmt, va_list args) /* {{{ */ +{ + va_list ap; + size_t len; + + va_copy(ap, args); + len = vsnprintf(buf, buf_size, fmt, ap); + va_end(ap); + + if (len >= buf_size) { + len = zlog_truncate_buf(buf, buf_size, 0); } + external_logger(flags & ZLOG_LEVEL_MASK, buf, len); +} +/* }}} */ + +static size_t zlog_buf_prefix( + const char *function, int line, int flags, + char *buf, size_t buf_size, int use_syslog) /* {{{ */ +{ + struct timeval tv; + size_t len = 0; - saved_errno = errno; #ifdef HAVE_SYSLOG_H - if (zlog_fd == ZLOG_SYSLOG /* && !fpm_globals.is_child */) { - len = 0; + if (use_syslog /* && !fpm_globals.is_child */) { if (zlog_level == ZLOG_DEBUG) { - len += snprintf(buf, buf_size, "[%s] %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], function, line); + len += snprintf(buf, buf_size, "[%s] %s(), line %d: ", + level_names[flags & ZLOG_LEVEL_MASK], function, line); } else { len += snprintf(buf, buf_size, "[%s] ", level_names[flags & ZLOG_LEVEL_MASK]); } @@ -143,20 +174,44 @@ void vzlog(const char *function, int line, int flags, const char *fmt, va_list a } if (zlog_level == ZLOG_DEBUG) { if (!fpm_globals.is_child) { - len += snprintf(buf + len, buf_size - len, "%s: pid %d, %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], getpid(), function, line); + len += snprintf(buf + len, buf_size - len, "%s: pid %d, %s(), line %d: ", + level_names[flags & ZLOG_LEVEL_MASK], getpid(), function, line); } else { - len += snprintf(buf + len, buf_size - len, "%s: %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], function, line); + len += snprintf(buf + len, buf_size - len, "%s: %s(), line %d: ", + level_names[flags & ZLOG_LEVEL_MASK], function, line); } } else { - len += snprintf(buf + len, buf_size - len, "%s: ", level_names[flags & ZLOG_LEVEL_MASK]); + len += snprintf(buf + len, buf_size - len, "%s: ", + level_names[flags & ZLOG_LEVEL_MASK]); } } - if (len > buf_size - 1) { - truncated = 1; + return len; +} +/* }}} */ + +void vzlog(const char *function, int line, int flags, const char *fmt, va_list args) /* {{{ */ +{ + char buf[MAX_BUF_LENGTH]; + size_t buf_size = MAX_BUF_LENGTH; + size_t len = 0; + int truncated = 0; + int saved_errno; + + if (external_logger) { + zlog_external(flags, buf, buf_size, fmt, args); } - if (!truncated) { + if ((flags & ZLOG_LEVEL_MASK) < zlog_level) { + return; + } + + saved_errno = errno; + len = zlog_buf_prefix(function, line, flags, buf, buf_size, zlog_fd == ZLOG_SYSLOG); + + if (len > buf_size - 1) { + truncated = 1; + } else { len += vsnprintf(buf + len, buf_size - len, fmt, args); if (len >= buf_size) { truncated = 1; @@ -165,16 +220,16 @@ void vzlog(const char *function, int line, int flags, const char *fmt, va_list a if (!truncated) { if (flags & ZLOG_HAVE_ERRNO) { - len += snprintf(buf + len, buf_size - len, ": %s (%d)", strerror(saved_errno), saved_errno); - if (len >= buf_size) { + len += snprintf(buf + len, buf_size - len, + ": %s (%d)", strerror(saved_errno), saved_errno); + if (len >= zlog_limit) { truncated = 1; } } } if (truncated) { - memcpy(buf + buf_size - sizeof("..."), "...", sizeof("...") - 1); - len = buf_size - 1; + len = zlog_truncate_buf(buf, zlog_limit < buf_size ? zlog_limit : buf_size, 1); } #ifdef HAVE_SYSLOG_H @@ -189,16 +244,627 @@ void vzlog(const char *function, int line, int flags, const char *fmt, va_list a zend_quiet_write(zlog_fd > -1 ? zlog_fd : STDERR_FILENO, buf, len); } - if (zlog_fd != STDERR_FILENO && zlog_fd != -1 && !launched && (flags & ZLOG_LEVEL_MASK) >= ZLOG_NOTICE) { + if (zlog_fd != STDERR_FILENO && zlog_fd != -1 && + !launched && (flags & ZLOG_LEVEL_MASK) >= ZLOG_NOTICE) { zend_quiet_write(STDERR_FILENO, buf, len); } } /* }}} */ -void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) /* {{{ */ { +void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) /* {{{ */ +{ va_list args; va_start(args, fmt); vzlog(function, line, flags, fmt, args); va_end(args); } /* }}} */ + +/* predefine stream init that is used by zlog_msg_ex */ +static inline void zlog_stream_init_internal( + struct zlog_stream *stream, int flags, size_t capacity, int fd); + +void zlog_msg_ex(const char *function, int line, int flags, + const char *prefix, const char *msg) /* {{{ */ +{ + struct zlog_stream stream; + size_t prefix_len = strlen(prefix); + size_t msg_len = strlen(msg); + + zlog_stream_init_internal(&stream, flags, msg_len + prefix_len, 0); + zlog_stream_prefix_ex(&stream, function, line); + zlog_stream_str(&stream, prefix, prefix_len); + zlog_stream_str(&stream, msg, msg_len); + zlog_stream_finish(&stream); + zlog_stream_destroy(&stream); +} +/* }}} */ + +/* STREAM OPS */ + +static zlog_bool zlog_stream_buf_alloc_ex(struct zlog_stream *stream, size_t needed) /* {{{ */ +{ + char *buf; + size_t size = stream->buf.size ?: stream->buf_init_size; + + if (stream->buf.data) { + size = MIN(zlog_limit, MAX(size * 2, needed)); + buf = realloc(stream->buf.data, size); + } else { + size = MIN(zlog_limit, MAX(size, needed)); + buf = malloc(size); + } + + if (buf == NULL) { + return 0; + } + + stream->buf.data = buf; + stream->buf.size = size; + + return 1; +} +/* }}} */ + +inline static zlog_bool zlog_stream_buf_alloc(struct zlog_stream *stream) /* {{{ */ +{ + /* if there is enough space in the buffer, we do not need to reallocate */ + if (stream->buf.data && stream->buf.size >= MIN(zlog_limit, stream->buf_init_size)) { + return 1; + } + return zlog_stream_buf_alloc_ex(stream, 0); +} +/* }}} */ + +static inline ssize_t zlog_stream_direct_write_ex( + struct zlog_stream *stream, const char *buf, size_t len, + const char *append, size_t append_len) /* {{{ */ +{ + if (stream->use_fd) { + zend_quiet_write(stream->fd, buf, len); + if (append_len > 0) { + zend_quiet_write(stream->fd, append, append_len); + } + } + + if (stream->use_stderr) { + zend_quiet_write(STDERR_FILENO, buf, len); + if (append_len > 0) { + zend_quiet_write(STDERR_FILENO, append, append_len); + } + } + + return len; +} +/* }}} */ + +static ssize_t zlog_stream_direct_write( + struct zlog_stream *stream, const char *buf, size_t len) /* {{{ */ +{ + return zlog_stream_direct_write_ex(stream, buf, len, NULL, 0); +} +/* }}} */ + +static inline ssize_t zlog_stream_unbuffered_write( + struct zlog_stream *stream, const char *buf, size_t len) /* {{{ */ +{ + const char *append; + size_t append_len = 0, required_len, reserved_len; + ssize_t written; + + if (stream->len == 0) { + stream->len = zlog_stream_prefix_ex(stream, stream->function, stream->line); + } + + /* msg_suffix_len and msg_quote are used only for wrapping */ + reserved_len = stream->len + stream->msg_suffix_len + stream->msg_quote; + required_len = reserved_len + len; + if (required_len >= zlog_limit) { + if (stream->wrap) { + size_t available_len; + if (required_len == zlog_limit) { + append = NULL; + append_len = 0; + } else { + append = "\n"; + append_len = 1; + } + available_len = zlog_limit - reserved_len - 1; + zlog_stream_direct_write(stream, buf, available_len); + if (append != NULL) { + if (stream->msg_quote) { + zlog_stream_direct_write(stream, "\"", 1); + } + if (stream->msg_suffix) { + zlog_stream_direct_write(stream, stream->msg_suffix, stream->msg_suffix_len); + } + zlog_stream_direct_write(stream, append, append_len); + } + stream->len = 0; + written = zlog_stream_unbuffered_write( + stream, buf + available_len, len - available_len); + if (written > 0) { + return available_len + written; + } + + return written; + } + /* this would be used in case of an option for disabling wrapping in direct write */ + stream->full = 1; + if (required_len == zlog_limit) { + append = NULL; + } else { + append = "..."; + append_len = sizeof("...") - 1; + len = zlog_limit - stream->len - append_len; + } + } + + written = zlog_stream_direct_write_ex(stream, buf, len, append, append_len); + if (written > 0) { + /* currently written will be always len as the write is blocking + * - this should be address if we change to non-blocking write */ + stream->len += written; + } + + return written; +} +/* }}} */ + +static inline ssize_t zlog_stream_buf_copy_cstr( + struct zlog_stream *stream, const char *str, size_t str_len) /* {{{ */ +{ + if (stream->buf.size - stream->len <= str_len && !zlog_stream_buf_alloc_ex(stream, str_len)) { + return -1; + } + + memcpy(stream->buf.data + stream->len, str, str_len); + stream->len += str_len; + + return str_len; +} +/* }}} */ + +static inline ssize_t zlog_stream_buf_copy_char(struct zlog_stream *stream, char c) /* {{{ */ +{ + if (stream->buf.size - stream->len < 1 && !zlog_stream_buf_alloc_ex(stream, 1)) { + return -1; + } + + stream->buf.data[stream->len++] = c; + + return 1; +} +/* }}} */ + +static ssize_t zlog_stream_buf_flush(struct zlog_stream *stream) /* {{{ */ +{ + ssize_t written; + +#ifdef HAVE_SYSLOG_H + if (stream->use_syslog) { + zlog_stream_buf_copy_char(stream, '\0'); + php_syslog(syslog_priorities[zlog_level], "%s", stream->buf.data); + --stream->len; + } +#endif + + if (external_logger != NULL) { + external_logger(stream->flags & ZLOG_LEVEL_MASK, + stream->buf.data + stream->prefix_len, stream->len - stream->prefix_len); + } + zlog_stream_buf_copy_char(stream, '\n'); + written = zlog_stream_direct_write(stream, stream->buf.data, stream->len); + stream->len = 0; + + return written; +} +/* }}} */ + +static ssize_t zlog_stream_buf_append( + struct zlog_stream *stream, const char *str, size_t str_len) /* {{{ */ +{ + int over_limit = 0; + size_t available_len, required_len, reserved_len; + + if (stream->len == 0) { + stream->len = zlog_stream_prefix_ex(stream, stream->function, stream->line); + } + + /* msg_suffix_len and msg_quote are used only for wrapping */ + reserved_len = stream->len + stream->msg_suffix_len + stream->msg_quote; + required_len = reserved_len + str_len; + if (required_len >= zlog_limit) { + over_limit = 1; + available_len = zlog_limit - reserved_len - 1; + } else { + available_len = str_len; + } + + if (zlog_stream_buf_copy_cstr(stream, str, available_len) < 0) { + return -1; + } + + if (!over_limit) { + return available_len; + } + + if (stream->wrap) { + if (stream->msg_quote) { + zlog_stream_buf_copy_char(stream, '"'); + } + if (stream->msg_suffix != NULL) { + zlog_stream_buf_copy_cstr(stream, stream->msg_suffix, stream->msg_suffix_len); + } + zlog_stream_buf_flush(stream); + zlog_stream_prefix_ex(stream, stream->function, stream->line); + return available_len + zlog_stream_buf_append( + stream, str + available_len, str_len - available_len); + } + + stream->len = zlog_truncate_buf(stream->buf.data, stream->len, 0); + stream->full = 1; + return available_len; +} +/* }}} */ + +static inline void zlog_stream_init_internal( + struct zlog_stream *stream, int flags, size_t capacity, int fd) /* {{{ */ +{ + if (fd == 0) { + fd = zlog_fd; + } + + memset(stream, 0, sizeof(struct zlog_stream)); + stream->flags = flags; + stream->use_syslog = fd == ZLOG_SYSLOG; + stream->use_fd = fd > 0; + stream->use_buffer = zlog_buffering || external_logger != NULL || stream->use_syslog; + stream->buf_init_size = capacity; + stream->use_stderr = fd < 0 || + ( + fd != STDERR_FILENO && fd != STDOUT_FILENO && !launched && + (flags & ZLOG_LEVEL_MASK) >= ZLOG_NOTICE + ); + stream->prefix_buffer = (flags & ZLOG_LEVEL_MASK) >= zlog_level && + (stream->use_fd || stream->use_stderr || stream->use_syslog); + stream->fd = fd > -1 ? fd : STDERR_FILENO; +} +/* }}} */ + +void zlog_stream_init(struct zlog_stream *stream, int flags) /* {{{ */ +{ + zlog_stream_init_internal(stream, flags, 1024, 0); +} +/* }}} */ + +void zlog_stream_init_ex(struct zlog_stream *stream, int flags, int fd) /* {{{ */ +{ + zlog_stream_init_internal(stream, flags, 1024, fd); + stream->wrap = 1; +} +/* }}} */ + +void zlog_stream_set_decorating(struct zlog_stream *stream, zlog_bool decorate) /* {{{ */ +{ + if (decorate) { + stream->decorate = 1; + } else { + stream->decorate = 0; + stream->msg_quote = 0; + stream->prefix_buffer = 0; + } +} +/* }}} */ + +void zlog_stream_set_wrapping(struct zlog_stream *stream, zlog_bool wrap) /* {{{ */ +{ + stream->wrap = wrap ? 1 : 0; +} +/* }}} */ + +void zlog_stream_set_is_stdout(struct zlog_stream *stream, zlog_bool is_stdout) /* {{{ */ +{ + stream->is_stdout = is_stdout ? 1 : 0; +} +/* }}} */ + +void zlog_stream_set_child_pid(struct zlog_stream *stream, int child_pid) /* {{{ */ +{ + stream->child_pid = child_pid; +} +/* }}} */ + +void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote) /* {{{ */ +{ + stream->msg_quote = quote && stream->decorate ? 1 : 0; +} +/* }}} */ + +zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...) /* {{{ */ +{ + char buf[MAX_WRAPPING_PREFIX_LENGTH]; + size_t len; + va_list args; + + if (!stream->decorate) { + return ZLOG_TRUE; + } + + va_start(args, fmt); + len = vsnprintf(buf, MAX_WRAPPING_PREFIX_LENGTH - 1, fmt, args); + va_end(args); + + if (stream->msg_prefix_len < len) { + stream->msg_prefix = stream->msg_prefix_len ? realloc(stream->msg_prefix, len + 1) : malloc(len + 1); + if (stream->msg_prefix == NULL) { + return ZLOG_FALSE; + } + } + memcpy(stream->msg_prefix, buf, len); + stream->msg_prefix[len] = 0; + stream->msg_prefix_len = len; + + return len; +} +/* }}} */ + +zlog_bool zlog_stream_set_msg_suffix( + struct zlog_stream *stream, const char *suffix, const char *final_suffix) /* {{{ */ +{ + size_t len; + if (!stream->wrap || !stream->decorate) { + return ZLOG_TRUE; + } + + if (suffix != NULL && final_suffix != NULL) { + stream->msg_suffix_len = strlen(suffix); + stream->msg_final_suffix_len = strlen(final_suffix); + len = stream->msg_suffix_len + stream->msg_final_suffix_len + 2; + if (stream->msg_suffix != NULL) { + free(stream->msg_suffix); + } + stream->msg_suffix = malloc(len); + if (stream->msg_suffix == NULL) { + return ZLOG_FALSE; + } + stream->msg_final_suffix = stream->msg_suffix + stream->msg_suffix_len + 1; + memcpy(stream->msg_suffix, suffix, stream->msg_suffix_len + 1); + memcpy(stream->msg_final_suffix, final_suffix, stream->msg_final_suffix_len + 1); + return ZLOG_TRUE; + } + if (suffix != NULL) { + stream->msg_suffix_len = strlen(suffix); + len = stream->msg_suffix_len + 1; + stream->msg_suffix = malloc(len); + if (stream->msg_suffix != NULL) { + free(stream->msg_suffix); + } + if (stream->msg_suffix == NULL) { + return ZLOG_FALSE; + } + memcpy(stream->msg_suffix, suffix, len); + return ZLOG_TRUE; + } + if (final_suffix != NULL) { + stream->msg_final_suffix_len = strlen(final_suffix); + len = stream->msg_final_suffix_len + 1; + stream->msg_final_suffix = malloc(len); + if (stream->msg_final_suffix != NULL) { + free(stream->msg_suffix); + } + if (stream->msg_final_suffix == NULL) { + return ZLOG_FALSE; + } + memcpy(stream->msg_final_suffix, final_suffix, len); + return ZLOG_TRUE; + } + + return ZLOG_TRUE; +} +/* }}} */ + +ssize_t zlog_stream_prefix_ex(struct zlog_stream *stream, const char *function, int line) /* {{{ */ +{ + size_t len; + + if (!stream->prefix_buffer) { + return 0; + } + if (stream->wrap && stream->function == NULL) { + stream->function = function; + stream->line = line; + } + + if (stream->use_buffer) { + if (!zlog_stream_buf_alloc(stream)) { + return -1; + } + len = zlog_buf_prefix( + function, line, stream->flags, + stream->buf.data, stream->buf.size, stream->use_syslog); + stream->len = stream->prefix_len = len; + if (stream->msg_prefix != NULL) { + zlog_stream_buf_copy_cstr(stream, stream->msg_prefix, stream->msg_prefix_len); + } + if (stream->msg_quote) { + zlog_stream_buf_copy_char(stream, '"'); + } + return stream->len; + } else { + char sbuf[1024]; + ssize_t written; + len = zlog_buf_prefix(function, line, stream->flags, sbuf, 1024, stream->use_syslog); + written = zlog_stream_direct_write(stream, sbuf, len); + if (stream->msg_prefix != NULL) { + written += zlog_stream_direct_write( + stream, stream->msg_prefix, stream->msg_prefix_len); + } + if (stream->msg_quote) { + written += zlog_stream_direct_write(stream, "\"", 1); + } + return written; + } +} +/* }}} */ + +ssize_t zlog_stream_vformat(struct zlog_stream *stream, const char *fmt, va_list args) /* {{{ */ +{ + char sbuf[1024]; + size_t len; + + len = vsnprintf(sbuf, 1024, fmt, args); + + return zlog_stream_str(stream, sbuf, len); +} +/* }}} */ + +ssize_t zlog_stream_format(struct zlog_stream *stream, const char *fmt, ...) /* {{{ */ +{ + ssize_t len; + + va_list args; + va_start(args, fmt); + len = zlog_stream_vformat(stream, fmt, args); + va_end(args); + + return len; +} +/* }}} */ + +ssize_t zlog_stream_str(struct zlog_stream *stream, const char *str, size_t str_len) /* {{{ */ +{ + /* reset stream if it is finished */ + if (stream->finished) { + stream->finished = 0; + stream->len = 0; + stream->full = 0; + } else if (stream->full) { + /* do not write anything if the stream is full */ + return 0; + } + + if (stream->use_buffer) { + return zlog_stream_buf_append(stream, str, str_len); + } + + return zlog_stream_unbuffered_write(stream, str, str_len); +} +/* }}} */ + +static inline void zlog_stream_finish_buffer_suffix(struct zlog_stream *stream) /* {{{ */ +{ + if (stream->msg_quote) { + zlog_stream_buf_copy_char(stream, '"'); + } + if (stream->msg_suffix != NULL) { + zlog_stream_buf_copy_cstr(stream, stream->msg_suffix, stream->msg_suffix_len); + } + if (stream->msg_final_suffix != NULL) { + if (stream->len + stream->msg_final_suffix_len >= zlog_limit) { + zlog_bool quoting = stream->msg_quote; + size_t final_suffix_wrap = stream->len + stream->msg_final_suffix_len + 1 - zlog_limit; + zlog_stream_buf_copy_cstr( + stream, stream->msg_final_suffix, + stream->msg_final_suffix_len - final_suffix_wrap); + zlog_stream_buf_copy_char(stream, '\n'); + zlog_stream_buf_flush(stream); + stream->msg_quote = 0; + zlog_stream_prefix_ex(stream, stream->function, stream->line); + stream->msg_quote = quoting; + zlog_stream_buf_copy_cstr( + stream, + stream->msg_final_suffix + (stream->msg_final_suffix_len - final_suffix_wrap), + final_suffix_wrap); + zlog_stream_buf_copy_char(stream, '\n'); + } else { + zlog_stream_buf_copy_cstr( + stream, stream->msg_final_suffix, stream->msg_final_suffix_len); + } + } +} +/* }}} */ + +static inline void zlog_stream_finish_direct_suffix(struct zlog_stream *stream) /* {{{ */ +{ + if (stream->msg_quote) { + zlog_stream_direct_write(stream, "\"", 1); + ++stream->len; + } + if (stream->msg_suffix != NULL) { + /* we should always have space for wrap suffix so we don't have to check it */ + zlog_stream_direct_write(stream, stream->msg_suffix, stream->msg_suffix_len); + stream->len += stream->msg_suffix_len; + } + if (stream->msg_final_suffix != NULL) { + if (stream->len + stream->msg_final_suffix_len >= zlog_limit) { + zlog_bool quoting = stream->msg_quote; + size_t final_suffix_wrap = stream->len + stream->msg_final_suffix_len + 1 - zlog_limit; + zlog_stream_direct_write_ex( + stream, stream->msg_final_suffix, + stream->msg_final_suffix_len - final_suffix_wrap, "\n", 1); + stream->msg_quote = 0; + zlog_stream_prefix_ex(stream, stream->function, stream->line); + stream->msg_quote = quoting; + zlog_stream_direct_write_ex( + stream, + stream->msg_final_suffix + (stream->msg_final_suffix_len - final_suffix_wrap), + final_suffix_wrap, "\n", 1); + } else { + zlog_stream_direct_write_ex( + stream, stream->msg_final_suffix, stream->msg_final_suffix_len, "\n", 1); + } + } else { + zlog_stream_direct_write(stream, "\n", 1); + } +} +/* }}} */ + +zlog_bool zlog_stream_finish(struct zlog_stream *stream) /* {{{ */ +{ + if (stream->finished || stream->len == 0) { + return ZLOG_TRUE; + } + + if (stream->use_buffer) { + if (stream->decorate) { + zlog_stream_finish_buffer_suffix(stream); + } + zlog_stream_buf_flush(stream); + } else { + if (stream->decorate) { + zlog_stream_finish_direct_suffix(stream); + } else { + zlog_stream_direct_write(stream, "\n", 1); + } + } + stream->finished = 1; + + return ZLOG_TRUE; +} +/* }}} */ + +void zlog_stream_destroy(struct zlog_stream *stream) /* {{{ */ +{ + if (stream->buf.data != NULL) { + free(stream->buf.data); + } + if (stream->msg_prefix != NULL) { + free(stream->msg_prefix); + } + if (stream->msg_suffix != NULL) { + free(stream->msg_suffix); + } else if (stream->msg_final_suffix != NULL) { + free(stream->msg_final_suffix); + } +} +/* }}} */ + +zlog_bool zlog_stream_close(struct zlog_stream *stream) /* {{{ */ +{ + zlog_bool finished = zlog_stream_finish(stream); + zlog_stream_destroy(stream); + + return finished; +} +/* }}} */ diff --git a/sapi/fpm/fpm/zlog.h b/sapi/fpm/fpm/zlog.h index 31a16fb88d..679996041b 100644 --- a/sapi/fpm/fpm/zlog.h +++ b/sapi/fpm/fpm/zlog.h @@ -1,18 +1,26 @@ - /* $Id: zlog.h,v 1.7 2008/05/22 21:08:32 anight Exp $ */ /* (c) 2004-2007 Andrei Nigmatulin */ #ifndef ZLOG_H #define ZLOG_H 1 #include <stdarg.h> +#include <sys/types.h> #define zlog(flags,...) zlog_ex(__func__, __LINE__, flags, __VA_ARGS__) +#define zlog_msg(flags, prefix, msg) zlog_msg_ex(__func__, __LINE__, flags, prefix, msg) struct timeval; +typedef unsigned char zlog_bool; + +#define ZLOG_TRUE 1 +#define ZLOG_FALSE 0 + void zlog_set_external_logger(void (*logger)(int, char *, size_t)); int zlog_set_fd(int new_fd); int zlog_set_level(int new_value); +int zlog_set_limit(int new_value); +int zlog_set_buffering(zlog_bool buffering); const char *zlog_get_level_name(int log_level); void zlog_set_launched(void); @@ -22,6 +30,9 @@ void vzlog(const char *function, int line, int flags, const char *fmt, va_list a void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) __attribute__ ((format(printf,4,5))); +void zlog_msg_ex(const char *function, int line, int flags, + const char *prefix, const char *msg); + #ifdef HAVE_SYSLOG_H extern const int syslog_priorities[]; #endif @@ -41,8 +52,71 @@ enum { #define ZLOG_SYSERROR (ZLOG_ERROR | ZLOG_HAVE_ERRNO) -#ifdef HAVE_SYSLOG_H #define ZLOG_SYSLOG -2 -#endif + +/* STREAM */ + +struct zlog_stream_buffer { + char *data; + size_t size; +}; + +struct zlog_stream { + int flags; + unsigned int use_syslog:1; + unsigned int use_fd:1; + unsigned int use_buffer:1; + unsigned int use_stderr:1; + unsigned int prefix_buffer:1; + unsigned int finished:1; + unsigned int full:1; + unsigned int wrap:1; + unsigned int msg_quote:1; + unsigned int decorate:1; + unsigned int is_stdout:1; + int fd; + int line; + int child_pid; + const char *function; + struct zlog_stream_buffer buf; + size_t len; + size_t buf_init_size; + size_t prefix_len; + char *msg_prefix; + size_t msg_prefix_len; + char *msg_suffix; + size_t msg_suffix_len; + char *msg_final_suffix; + size_t msg_final_suffix_len; +}; + +void zlog_stream_init(struct zlog_stream *stream, int flags); +void zlog_stream_init_ex(struct zlog_stream *stream, int flags, int fd); +void zlog_stream_set_decorating(struct zlog_stream *stream, zlog_bool decorate); +void zlog_stream_set_wrapping(struct zlog_stream *stream, zlog_bool wrap); +void zlog_stream_set_is_stdout(struct zlog_stream *stream, zlog_bool is_stdout); +void zlog_stream_set_child_pid(struct zlog_stream *stream, int child_pid); +void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote); +zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...) + __attribute__ ((format(printf,2,3))); +zlog_bool zlog_stream_set_msg_suffix( + struct zlog_stream *stream, const char *suffix, const char *final_suffix); +#define zlog_stream_prefix(stream) \ + zlog_stream_prefix_ex(stream, __func__, __LINE__) +ssize_t zlog_stream_prefix_ex(struct zlog_stream *stream, const char *function, int line); +ssize_t zlog_stream_format(struct zlog_stream *stream, const char *fmt, ...) + __attribute__ ((format(printf,2,3))); +ssize_t zlog_stream_vformat(struct zlog_stream *stream, const char *fmt, va_list args); +ssize_t zlog_stream_str(struct zlog_stream *stream, const char *str, size_t str_len); +zlog_bool zlog_stream_finish(struct zlog_stream *stream); +void zlog_stream_destroy(struct zlog_stream *stream); +zlog_bool zlog_stream_close(struct zlog_stream *stream); + +/* default log limit */ +#define ZLOG_DEFAULT_LIMIT 1024 +/* minimum log limit */ +#define ZLOG_MIN_LIMIT 512 +/* default log buffering */ +#define ZLOG_DEFAULT_BUFFERING 1 #endif diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index 56c18e862a..7f21aaa960 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -41,6 +41,24 @@ ; Default Value: notice ;log_level = notice +; Log limit on number of characters in the single line (log entry). If the +; line is over the limit, it is wrapped on multiple lines. The limit is for +; all logged characters including message prefix and suffix if present. However +; the new line character does not count into it as it is present only when +; logging to a file descriptor. It means the new line character is not present +; when logging to syslog. +; Default Value: 1024 +;log_limit = 4096 + +; Log buffering specifies if the log line is buffered which means that the +; line is written in a single write operation. If the value is false, then the +; data is written directly into the file descriptor. It is an experimental +; option that can potentionaly improve logging performance and memory usage +; for some heavy logging scenarios. This option is ignored if logging to syslog +; as it has to be always buffered. +; Default value: yes +;log_buffering = no + ; If this number of child processes exit with SIGSEGV or SIGBUS within the time ; interval set by emergency_restart_interval then FPM will restart. A value ; of '0' means 'Off'. diff --git a/sapi/fpm/status.html.in b/sapi/fpm/status.html.in index 2440638d54..d3b6d5efd3 100644 --- a/sapi/fpm/status.html.in +++ b/sapi/fpm/status.html.in @@ -1,7 +1,6 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- - $Id$ (c) 2011 Jerome Loyet The PHP License, version 3.01 This is sample real-time status page for FPM. You can change it to better fit your needs. diff --git a/sapi/fpm/tests/fpm_get_status_basic.phpt b/sapi/fpm/tests/fpm_get_status_basic.phpt new file mode 100644 index 0000000000..d72a1f4d70 --- /dev/null +++ b/sapi/fpm/tests/fpm_get_status_basic.phpt @@ -0,0 +1,112 @@ +--TEST-- +FPM: Function fpm_get_status basic test +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +EOT; + +$code = <<<EOT +<?php +echo "Test Start\n"; +var_dump(fpm_get_status()); +echo "Test End\n"; +EOT; + +$headers = []; +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->printBody(); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECTF-- +Test Start +array(15) { + ["pool"]=> + string(10) "unconfined" + ["process-manager"]=> + string(7) "dynamic" + ["start-time"]=> + int(%d) + ["start-since"]=> + int(%d) + ["accepted-conn"]=> + int(1) + ["listen-queue"]=> + int(0) + ["max-listen-queue"]=> + int(0) + ["listen-queue-len"]=> + int(%d) + ["idle-processes"]=> + int(0) + ["active-processes"]=> + int(1) + ["total-processes"]=> + int(1) + ["max-active-processes"]=> + int(1) + ["max-children-reached"]=> + int(0) + ["slow-requests"]=> + int(0) + ["procs"]=> + array(1) { + [0]=> + array(14) { + ["pid"]=> + int(%d) + ["state"]=> + string(7) "Running" + ["start-time"]=> + int(%d) + ["start-since"]=> + int(%d) + ["requests"]=> + int(1) + ["request-duration"]=> + int(%d) + ["request-method"]=> + string(3) "GET" + ["request-uri"]=> + string(%d) "%s" + ["query-string"]=> + string(0) "" + ["request-length"]=> + int(0) + ["user"]=> + string(1) "-" + ["script"]=> + string(%d) "%s" + ["last-request-cpu"]=> + float(0) + ["last-request-memory"]=> + int(0) + } + } +} +Test End +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/getallheaders.phpt b/sapi/fpm/tests/getallheaders.phpt new file mode 100644 index 0000000000..b1f9683788 --- /dev/null +++ b/sapi/fpm/tests/getallheaders.phpt @@ -0,0 +1,67 @@ +--TEST-- +FPM: Function getallheaders basic test +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +EOT; + +$code = <<<EOT +<?php +echo "Test Start\n"; +var_dump(getallheaders()); +echo "Test End\n"; +EOT; + +$headers = []; +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request( + '', + [ + 'HTTP_X_FOO' => 'BAR', + 'HTTP_FOO' => 'foo' + ] + )->expectBody( + [ + 'Test Start', + 'array(4) {', + ' ["Foo"]=>', + ' string(3) "foo"', + ' ["X-Foo"]=>', + ' string(3) "BAR"', + ' ["Content-Length"]=>', + ' string(1) "0"', + ' ["Content-Type"]=>', + ' string(0) ""', + '}', + 'Test End', + ] + ); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bm-limit-1024-msg-80.phpt b/sapi/fpm/tests/log-bm-limit-1024-msg-80.phpt new file mode 100644 index 0000000000..940d0df6e9 --- /dev/null +++ b/sapi/fpm/tests/log-bm-limit-1024-msg-80.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Buffered message output log with limit 1024 and msg 80 +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1024 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +error_log(str_repeat('e', 80)); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectFastCGIErrorMessage('e', 1050, 80); +$tester->expectLogMessage('NOTICE: PHP message: ' . str_repeat('e', 80), 1050); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bm-limit-2048-msg-4000.phpt b/sapi/fpm/tests/log-bm-limit-2048-msg-4000.phpt new file mode 100644 index 0000000000..5354671ee2 --- /dev/null +++ b/sapi/fpm/tests/log-bm-limit-2048-msg-4000.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Buffered message output log with limit 2048 and msg 4000 +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 2048 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +error_log(str_repeat('t', 4000)); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectFastCGIErrorMessage('t', 2048, 4000); +$tester->expectLogMessage('NOTICE: PHP message: ' . str_repeat('t', 2023) . '...', 2048); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-limit-1050-msg-2048.phpt b/sapi/fpm/tests/log-bwd-limit-1050-msg-2048.phpt new file mode 100644 index 0000000000..6552428745 --- /dev/null +++ b/sapi/fpm/tests/log-bwd-limit-1050-msg-2048.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Buffered worker output decorated log with limit 1050 with 2048 msg +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1050 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +decorate_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 2048) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1050, 2048); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-limit-1050-msg-2900.phpt b/sapi/fpm/tests/log-bwd-limit-1050-msg-2900.phpt new file mode 100644 index 0000000000..c528804292 --- /dev/null +++ b/sapi/fpm/tests/log-bwd-limit-1050-msg-2900.phpt @@ -0,0 +1,46 @@ +--TEST-- +FPM: Buffered worker output decorated log with limit 1050 with 2900 msg +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1050 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 2900) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1050, 2900); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-limit-64-too-low-error.phpt b/sapi/fpm/tests/log-bwd-limit-64-too-low-error.phpt new file mode 100644 index 0000000000..2259ecb149 --- /dev/null +++ b/sapi/fpm/tests/log-bwd-limit-64-too-low-error.phpt @@ -0,0 +1,42 @@ +--TEST-- +FPM: Buffered worker output decorated log with limit 64 fails because it is too low +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 64 +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 2048) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogError('log_limit must be greater than 512'); +$tester->close(true); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-limit-8000-msg-4096.phpt b/sapi/fpm/tests/log-bwd-limit-8000-msg-4096.phpt new file mode 100644 index 0000000000..fc8fbe1fe8 --- /dev/null +++ b/sapi/fpm/tests/log-bwd-limit-8000-msg-4096.phpt @@ -0,0 +1,46 @@ +--TEST-- +FPM: Buffered worker output decorated log with limit 8000 with 4096 msg +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 8000 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 4096) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 8000, 4096); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-msg-with-nl.phpt b/sapi/fpm/tests/log-bwd-msg-with-nl.phpt new file mode 100644 index 0000000000..67a793f8a0 --- /dev/null +++ b/sapi/fpm/tests/log-bwd-msg-with-nl.phpt @@ -0,0 +1,46 @@ +--TEST-- +FPM: Buffered worker output decorated log with msg containing new lines +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', "msg 1\nmsg 2\nmsg 3"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogLine('msg 1'); +$tester->expectLogLine('msg 2'); +$tester->expectLogLine('msg 3'); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt b/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt new file mode 100644 index 0000000000..376a972bac --- /dev/null +++ b/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt @@ -0,0 +1,50 @@ +--TEST-- +FPM: Buffered worker output decorated log with multiple continuous messages (stdout/stderr mixed) +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stdout', "msg 1 - "); +usleep(1); +file_put_contents('php://stderr', "msg 2 - "); +usleep(1); +file_put_contents('php://stderr', "msg 3"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogLine('msg 1 - ', false); +$tester->expectLogLine('msg 2 - msg 3', true); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwd-multiple-msgs.phpt b/sapi/fpm/tests/log-bwd-multiple-msgs.phpt new file mode 100644 index 0000000000..1517f4a554 --- /dev/null +++ b/sapi/fpm/tests/log-bwd-multiple-msgs.phpt @@ -0,0 +1,50 @@ +--TEST-- +FPM: Buffered worker output decorated log with multiple continuous messages +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', "msg 1 - "); +usleep(1); +file_put_contents('php://stderr', "msg 2 - "); +usleep(1); +file_put_contents('php://stderr', "msg 3"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogLine('msg 1 - msg 2 - msg 3'); +$tester->expectLogLine('msg 1 - msg 2 - msg 3'); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwp-limit-1024-msg-120.phpt b/sapi/fpm/tests/log-bwp-limit-1024-msg-120.phpt new file mode 100644 index 0000000000..5a62285eda --- /dev/null +++ b/sapi/fpm/tests/log-bwp-limit-1024-msg-120.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Buffered worker output plain log with limit 1024 and msg 120 +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1024 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +decorate_workers_output = no +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 120) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1024, 120, false); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-bwp-limit-1500-msg-3300.phpt b/sapi/fpm/tests/log-bwp-limit-1500-msg-3300.phpt new file mode 100644 index 0000000000..10674935cc --- /dev/null +++ b/sapi/fpm/tests/log-bwp-limit-1500-msg-3300.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Buffered worker output plain log with limit 1500 and msg 3300 +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1500 +log_buffering = yes +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +decorate_workers_output = no +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 3300) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1500, 3300, false); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-dwd-limit-1050-msg-2048.phpt b/sapi/fpm/tests/log-dwd-limit-1050-msg-2048.phpt new file mode 100644 index 0000000000..5162206cdd --- /dev/null +++ b/sapi/fpm/tests/log-dwd-limit-1050-msg-2048.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Direct worker output decorated log with limit 1050 with 2048 msg +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1050 +log_buffering = no +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +decorate_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 2048) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1050, 2048); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-dwd-limit-1050-msg-2900.phpt b/sapi/fpm/tests/log-dwd-limit-1050-msg-2900.phpt new file mode 100644 index 0000000000..fe08be6d3c --- /dev/null +++ b/sapi/fpm/tests/log-dwd-limit-1050-msg-2900.phpt @@ -0,0 +1,46 @@ +--TEST-- +FPM: Direct worker output decorated log with limit 1050 with 2900 msg +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1050 +log_buffering = no +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 2900) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1050, 2900); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-dwd-limit-8000-msg-4096.phpt b/sapi/fpm/tests/log-dwd-limit-8000-msg-4096.phpt new file mode 100644 index 0000000000..351473fc2c --- /dev/null +++ b/sapi/fpm/tests/log-dwd-limit-8000-msg-4096.phpt @@ -0,0 +1,46 @@ +--TEST-- +FPM: Direct worker output decorated log with limit 8000 with 4096 msg +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 8000 +log_buffering = no +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 4096) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 8000, 4096); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/log-dwp-limit-1000-msg-2000.phpt b/sapi/fpm/tests/log-dwp-limit-1000-msg-2000.phpt new file mode 100644 index 0000000000..61cb92331e --- /dev/null +++ b/sapi/fpm/tests/log-dwp-limit-1000-msg-2000.phpt @@ -0,0 +1,47 @@ +--TEST-- +FPM: Direct worker output plain log with limit 1000 and msg 2000 +--SKIPIF-- +<?php include "skipif.inc"; ?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_limit = 1000 +log_buffering = no +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes +decorate_workers_output = no +EOT; + +$code = <<<EOT +<?php +file_put_contents('php://stderr', str_repeat('a', 2000) . "\n"); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->terminate(); +$tester->expectLogMessage('a', 1000, 2000, false); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/logtool.inc b/sapi/fpm/tests/logtool.inc index 219c6fedbb..78523635d0 100644 --- a/sapi/fpm/tests/logtool.inc +++ b/sapi/fpm/tests/logtool.inc @@ -6,6 +6,7 @@ class LogTool { const P_TIME = '\[\d\d-\w\w\w-\d{4} \d\d:\d\d:\d\d\]'; const P_PREFIX = '\[pool unconfined\] child \d+ said into stderr: '; + const P_PREFIX_STDOUT = '\[pool unconfined\] child \d+ said into stdout: '; const FINAL_SUFFIX = ', pipe is closed'; /** @@ -44,6 +45,11 @@ class LogTool private $error; /** + * @var bool + */ + private $pipeClosed = false; + + /** * @param string $message * @param int $limit * @param int $repeat @@ -73,6 +79,14 @@ class LogTool } /** + * @param bool $pipeClosed + */ + public function setPipeClosed(bool $pipeClosed) + { + $this->pipeClosed = $pipeClosed; + } + + /** * @param string $line * @return bool */ @@ -90,7 +104,7 @@ class LogTool return $this->error("Unexpected truncated message: {$line}"); } - if ($lineLen === $this->limit) { + if ($lineLen === $this->limit - strlen('NOTICE: ') - 1) { if (!isset($matches[2])) { return $this->error("The truncated line is not ended with '...'"); } @@ -117,7 +131,7 @@ class LogTool * @param bool $decorated * @return bool */ - public function checkWrappedMessage(array $lines, bool $terminated = true, bool $decorated = true) + public function checkWrappedMessage(array $lines, bool $terminated = true, bool $decorated = true, bool $is_stderr = true) { if ($this->message === null) { throw new \LogicException('The message has not been set'); @@ -127,7 +141,7 @@ class LogTool '/^(%s %s: %s)"([^"]*)"(.*)?$/', self::P_TIME, $this->getExpectedLevel(), - self::P_PREFIX + $is_stderr ? self::P_PREFIX : self::P_PREFIX_STDOUT ); } else { $this->pattern = null; @@ -144,7 +158,7 @@ class LogTool $suffixPattern = sprintf( '/^%s %s: %s(.*)$/', self::P_TIME, $this->getExpectedLevel(), - self::P_PREFIX + $is_stderr ? self::P_PREFIX : self::P_PREFIX_STDOUT ); $line = $lines[++$idx]; if (preg_match($suffixPattern, $line, $matches) === 0) { @@ -205,13 +219,13 @@ class LogTool if ($rem !== $outLen) { return $this->error("Printed more than the message len"); } - if ($finalSuffix === null || $finalSuffix === "") { + if (!$this->pipeClosed || $finalSuffix === null) { return false; } if ($finalSuffix === false) { return $this->error("No final suffix"); } - if (strpos(self::FINAL_SUFFIX, $finalSuffix) === false) { + if (empty($finalSuffix) || strpos(self::FINAL_SUFFIX, $finalSuffix) === false) { return $this->error("The final suffix has to be equal to ', pipe is closed'"); } if (self::FINAL_SUFFIX !== $finalSuffix) { diff --git a/sapi/fpm/tests/response.inc b/sapi/fpm/tests/response.inc index 24285bf560..54f85bcfb6 100644 --- a/sapi/fpm/tests/response.inc +++ b/sapi/fpm/tests/response.inc @@ -124,7 +124,7 @@ class Response */ public function printBody() { - echo $this->getBody(); + echo $this->getBody() . "\n"; } /** diff --git a/sapi/fpm/tests/tester.inc b/sapi/fpm/tests/tester.inc index 70c03ad70f..001b7d6a54 100644 --- a/sapi/fpm/tests/tester.inc +++ b/sapi/fpm/tests/tester.inc @@ -1080,7 +1080,7 @@ class Tester * @param string $message * @return bool */ - public function expectLogLine(string $message) + public function expectLogLine(string $message, bool $is_stderr = true) { $messageLen = strlen($message); $limit = $messageLen > 1024 ? $messageLen + 16 : 1024; @@ -1090,7 +1090,7 @@ class Tester $this->message("LOG LINE: " . ($logLines[0] ?? '')); } - return $this->logTool->checkWrappedMessage($logLines, false); + return $this->logTool->checkWrappedMessage($logLines, false, true, $is_stderr); } /** diff --git a/sapi/fpm/www.conf.in b/sapi/fpm/www.conf.in index ccfdbd9e87..092dec4fff 100644 --- a/sapi/fpm/www.conf.in +++ b/sapi/fpm/www.conf.in @@ -339,6 +339,14 @@ pm.max_spare_servers = 3 ; Default Value: 0 ;request_terminate_timeout = 0 +; The timeout set by 'request_terminate_timeout' ini option is not engaged after +; application calls 'fastcgi_finish_request' or when application has finished and +; shutdown functions are being called (registered via register_shutdown_function). +; This option will enable timeout limit to be applied unconditionally +; even in such cases. +; Default Value: no +;request_terminate_timeout_track_finished = no + ; Set open file descriptor rlimit. ; Default Value: system defined value ;rlimit_files = 1024 @@ -371,6 +379,13 @@ pm.max_spare_servers = 3 ; Default Value: no ;catch_workers_output = yes +; Decorate worker output with prefix and suffix containing information about +; the child that writes to the log and if stdout or stderr is used as well as +; log level and time. This options is used only if catch_workers_output is yes. +; Settings to "no" will output data as written to the stdout or stderr. +; Default value: yes +;decorate_workers_output = no + ; Clear environment in FPM workers ; Prevents arbitrary environment variables from reaching FPM worker processes ; by clearing the environment in workers before env vars specified in this diff --git a/sapi/litespeed/config.m4 b/sapi/litespeed/config.m4 index 36e614c853..eba8642eb4 100644 --- a/sapi/litespeed/config.m4 +++ b/sapi/litespeed/config.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi litespeed AC_MSG_CHECKING(for LiteSpeed support) diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 8f02f15c32..d3ac79eb7b 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -37,18 +37,7 @@ #include <unistd.h> #endif -#ifdef PHP_WIN32 - -#include <io.h> -#include <fcntl.h> -#include "win32/php_registry.h" - -#else - #include <sys/wait.h> - -#endif - #include <sys/stat.h> #if HAVE_SYS_TYPES_H @@ -248,14 +237,14 @@ static void litespeed_php_import_environment_variables(zval *array_ptr) Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) && zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0 ) { - zval_dtor(array_ptr); + zval_ptr_dtor_nogc(array_ptr); ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]); return; } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) && zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0 ) { - zval_dtor(array_ptr); + zval_ptr_dtor_nogc(array_ptr); ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]); return; } @@ -569,8 +558,8 @@ static int lsapi_activate_user_ini(); static int sapi_lsapi_activate() { - char *path, *doc_root, *server_name; - size_t path_len, doc_root_len, server_name_len; + char *path, *server_name; + size_t path_len, server_name_len; /* PATH_TRANSLATED should be defined at this stage but better safe than sorry :) */ if (!SG(request_info).path_translated) { @@ -849,7 +838,7 @@ static int alter_ini( const char * pKey, int keyLen, const char * pValue, int va zend_alter_ini_entry_chars(psKey, (char *)pValue, valLen, type, stage); - zend_string_release(psKey); + zend_string_release_ex(psKey, 1); } } return 1; @@ -1267,13 +1256,6 @@ static int cli_main( int argc, char * argv[] ) zend_string *psKey; lsapi_mode = 0; /* enter CLI mode */ -#ifdef PHP_WIN32 - _fmode = _O_BINARY; /*sets default for file streams to binary */ - setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ -#endif - zend_first_try { SG(server_context) = (void *) 1; @@ -1281,12 +1263,15 @@ static int cli_main( int argc, char * argv[] ) CG(in_compilation) = 0; /* not initialized but needed for several options */ SG(options) |= SAPI_OPTION_NO_CHDIR; +#if PHP_MAJOR_VERSION < 7 + EG(uninitialized_zval_ptr) = NULL; +#endif for( ini = ini_defaults; *ini; ini+=2 ) { psKey = zend_string_init(*ini, strlen( *ini ), 1); zend_alter_ini_entry_chars(psKey, (char *)*(ini+1), strlen( *(ini+1) ), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); - zend_string_release(psKey); + zend_string_release_ex(psKey, 1); } while (( p < argend )&&(**p == '-' )) { @@ -1598,7 +1583,6 @@ int main( int argc, char * argv[] ) php_bind = NULL; } - int iRequestsProcessed = 0; int result; atexit(lsapi_atexit); @@ -1656,7 +1640,7 @@ PHP_FUNCTION(litespeed_finish_request); PHP_MINFO_FUNCTION(litespeed); -zend_function_entry litespeed_functions[] = { +static const zend_function_entry litespeed_functions[] = { PHP_FE(litespeed_request_headers, arginfo_litespeed__void) PHP_FE(litespeed_response_headers, arginfo_litespeed__void) PHP_FE(apache_get_modules, arginfo_litespeed__void) diff --git a/sapi/litespeed/lscriu.c b/sapi/litespeed/lscriu.c index 661d6bfb93..1318214f58 100644 --- a/sapi/litespeed/lscriu.c +++ b/sapi/litespeed/lscriu.c @@ -258,7 +258,6 @@ static int LSCRIU_load_liblscapi(void) { void *lib_handle = NULL; void *pthread_lib_handle = NULL; - char ch; if (s_native) return 0; @@ -470,7 +469,6 @@ static void LSCRIU_CloudLinux_Checkpoint(void) iRet = s_lscapi_dump_me(); if (iRet < 0) { - char *pchError; lscriu_err("LSCRIU: CloudLinux dump of PID: %d, error: %s\n", s_pid, strerror(errno)); } @@ -526,31 +524,28 @@ static void LSCRIU_try_checkpoint(int *forked_pid) if (s_tried_checkpoint) { lscriu_dbg("LSCRIU (%d): Already tried checkpoint - one time per customer\n", - getpid()); + iPidDump); return; } - lscriu_dbg("LSCRIU (%d): Trying checkpoint\n", getpid()); + lscriu_dbg("LSCRIU (%d): Trying checkpoint\n", iPidDump); s_tried_checkpoint = 1; if (!s_native) { LSCRIU_CloudLinux_Checkpoint(); return; } - lscriu_dbg("LSCRIU (%d): fork!\n", getpid()); + lscriu_dbg("LSCRIU (%d): fork!\n", iPidDump); iPid = fork(); if (iPid < 0) { lscriu_err("LSCRIU (%d): Can't checkpoint due to a fork error: %s\n", - getpid(), strerror(errno)); + iPidDump, strerror(errno)); return; } if (iPid == 0) { - int iResult; - pid_t iPidSender; pid_t iPidParent = getppid(); - s_pid = getpid(); setsid(); - iRet = LSCRIU_Native_Dump(s_pid, + iRet = LSCRIU_Native_Dump(iPidDump, s_criu_image_path, s_fd_native); close(s_fd_native); @@ -661,7 +656,6 @@ static int LSCRIU_Init_Env_Parameters(void) lscriu_dbg("LSCRIU (%d): NOT Listening\n", getpid()); char *criu_mode = NULL; - char ch; criu_mode = getenv("LSAPI_CRIU"); // 0 disabled // 1 cloudlinux diff --git a/sapi/phpdbg/.gitignore b/sapi/phpdbg/.gitignore deleted file mode 100644 index 51165dab2f..0000000000 --- a/sapi/phpdbg/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.libs/ -phpdbg -*.lo -*.o -*.output -build diff --git a/sapi/phpdbg/.travis.yml b/sapi/phpdbg/.travis.yml deleted file mode 100644 index 2e777fbe13..0000000000 --- a/sapi/phpdbg/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: c - -env: -- PHP="PHP-5.4" -- PHP="PHP-5.5" -- PHP="PHP-5.6" - -before_script: ./travis/ci.sh - -script: -- ./php-src/sapi/cli/php php-src/sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg php-src/sapi/phpdbg/phpdbg diff --git a/sapi/phpdbg/README.md b/sapi/phpdbg/README.md index a2a84deb7b..6eccb512de 100644 --- a/sapi/phpdbg/README.md +++ b/sapi/phpdbg/README.md @@ -5,8 +5,6 @@ Implemented as a SAPI module, phpdbg can exert complete control over the environ phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP 5.4+ -[](https://travis-ci.org/krakjoe/phpdbg) - Features ======== @@ -80,4 +78,4 @@ Getting Started See the website for tutorials/documentation -http://phpdbg.com +https://phpdbg.room11.org diff --git a/sapi/phpdbg/config.m4 b/sapi/phpdbg/config.m4 index 3cdd90495a..24bc557c8b 100644 --- a/sapi/phpdbg/config.m4 +++ b/sapi/phpdbg/config.m4 @@ -1,15 +1,14 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for sapi phpdbg PHP_ARG_ENABLE(phpdbg, for phpdbg support, -[ --enable-phpdbg Build phpdbg], yes, yes) +[ --enable-phpdbg Build phpdbg], yes, yes) PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support, -[ --enable-phpdbg-webhelper Build phpdbg web SAPI support], no) +[ --enable-phpdbg-webhelper + Build phpdbg web SAPI support], no) PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, -[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) +[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) PHP_ARG_ENABLE(phpdbg-readline, for phpdbg readline support, [ --enable-phpdbg-readline Enable readline support in phpdbg (depends on static ext/readline)], no, no) @@ -58,6 +57,7 @@ if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then \$(EXTRA_LIBS) \ \$(PHPDBG_EXTRA_LIBS) \ \$(ZEND_EXTRA_LIBS) \ + \$(PHP_FRAMEWORKS) \ -o \$(BUILD_BINARY)" BUILD_PHPDBG_SHARED="\$(LIBTOOL) --mode=link \ diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 2a5ea29a0b..03aaf54431 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -121,8 +121,7 @@ static void php_phpdbg_destroy_bp_condition(zval *data) /* {{{ */ static void php_phpdbg_destroy_registered(zval *data) /* {{{ */ { - zend_function *function = (zend_function *) Z_PTR_P(data); - destroy_zend_function(function); + zend_function_dtor(data); } /* }}} */ static void php_phpdbg_destroy_file_source(zval *data) /* {{{ */ @@ -210,11 +209,6 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ REGISTER_STRINGL_CONSTANT("PHPDBG_VERSION", PHPDBG_VERSION, sizeof(PHPDBG_VERSION)-1, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PHPDBG_COLOR_PROMPT", PHPDBG_COLOR_PROMPT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_COLOR_NOTICE", PHPDBG_COLOR_NOTICE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_COLOR_ERROR", PHPDBG_COLOR_ERROR, CONST_CS|CONST_PERSISTENT); @@ -370,7 +364,7 @@ static PHP_FUNCTION(phpdbg_break_next) phpdbg_set_breakpoint_opline_ex((phpdbg_opline_ptr_t) ex->opline + 1); } /* }}} */ -/* {{{ proto void phpdbg_break_file(string file, integer line) */ +/* {{{ proto void phpdbg_break_file(string file, int line) */ static PHP_FUNCTION(phpdbg_break_file) { char *file; @@ -425,7 +419,7 @@ static PHP_FUNCTION(phpdbg_clear) zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); } /* }}} */ -/* {{{ proto void phpdbg_color(integer element, string color) */ +/* {{{ proto void phpdbg_color(int element, string color) */ static PHP_FUNCTION(phpdbg_color) { zend_long element; @@ -580,10 +574,10 @@ static PHP_FUNCTION(phpdbg_get_executable) zend_hash_add_empty_element(files, zval_get_string(filename)); } ZEND_HASH_FOREACH_END(); } else { - GC_REFCOUNT(files)++; + GC_ADDREF(files); } } else { - GC_REFCOUNT(files)++; + GC_ADDREF(files); } array_init(return_value); @@ -632,7 +626,7 @@ static PHP_FUNCTION(phpdbg_get_executable) } } ZEND_HASH_FOREACH_END(); - if (!--GC_REFCOUNT(files)) { + if (!GC_DELREF(files)) { zend_hash_destroy(files); } } @@ -783,7 +777,7 @@ ZEND_BEGIN_ARG_INFO_EX(phpdbg_get_executable_arginfo, 0, 0, 0) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() -zend_function_entry phpdbg_user_functions[] = { +static const zend_function_entry phpdbg_user_functions[] = { PHP_FE(phpdbg_clear, phpdbg_clear_arginfo) PHP_FE(phpdbg_break_next, phpdbg_break_next_arginfo) PHP_FE(phpdbg_break_file, phpdbg_break_file_arginfo) @@ -1019,23 +1013,20 @@ void phpdbg_register_file_handles(void) /* {{{ */ php_stream_to_zval(s_err, &zerr); ic.value = zin; - ic.flags = CONST_CS; + ZEND_CONSTANT_SET_FLAGS(&ic, CONST_CS, 0); ic.name = zend_string_init(ZEND_STRL("STDIN"), 0); - ic.module_number = 0; zend_hash_del(EG(zend_constants), ic.name); zend_register_constant(&ic); oc.value = zout; - oc.flags = CONST_CS; + ZEND_CONSTANT_SET_FLAGS(&oc, CONST_CS, 0); oc.name = zend_string_init(ZEND_STRL("STDOUT"), 0); - oc.module_number = 0; zend_hash_del(EG(zend_constants), oc.name); zend_register_constant(&oc); ec.value = zerr; - ec.flags = CONST_CS; + ZEND_CONSTANT_SET_FLAGS(&ec, CONST_CS, 0); ec.name = zend_string_init(ZEND_STRL("STDERR"), 0); - ec.module_number = 0; zend_hash_del(EG(zend_constants), ec.name); zend_register_constant(&ec); } @@ -1356,7 +1347,7 @@ php_stream *phpdbg_stream_url_wrap_php(php_stream_wrapper *wrapper, const char * return stream; } - return PHPDBG_G(orig_url_wrap_php)(wrapper, path, mode, options, opened_path, context STREAMS_CC); + return PHPDBG_G(orig_url_wrap_php)->wops->stream_opener(wrapper, path, mode, options, opened_path, context STREAMS_CC); } /* }}} */ int main(int argc, char **argv) /* {{{ */ @@ -1399,6 +1390,8 @@ int main(int argc, char **argv) /* {{{ */ void* (*_malloc)(size_t); void (*_free)(void*); void* (*_realloc)(void*, size_t); + php_stream_wrapper wrapper; + php_stream_wrapper_ops wops; #ifndef _WIN32 @@ -1872,9 +1865,14 @@ phpdbg_main: } { - php_stream_wrapper *wrapper = zend_hash_str_find_ptr(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php")); - PHPDBG_G(orig_url_wrap_php) = wrapper->wops->stream_opener; - wrapper->wops->stream_opener = phpdbg_stream_url_wrap_php; + zval *zv = zend_hash_str_find(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php")); + php_stream_wrapper *tmp_wrapper = Z_PTR_P(zv); + PHPDBG_G(orig_url_wrap_php) = tmp_wrapper; + memcpy(&wrapper, tmp_wrapper, sizeof(wrapper)); + memcpy(&wops, tmp_wrapper->wops, sizeof(wops)); + wops.stream_opener = phpdbg_stream_url_wrap_php; + wrapper.wops = (const php_stream_wrapper_ops*)&wops; + Z_PTR_P(zv) = &wrapper; } /* Make stdin, stdout and stderr accessible from PHP scripts */ @@ -2101,6 +2099,7 @@ phpdbg_out: if (PHPDBG_G(exec) && strcmp("Standard input code", PHPDBG_G(exec)) == SUCCESS) { /* i.e. execution context has been read from stdin - back it up */ phpdbg_file_source *data = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), PHPDBG_G(exec), PHPDBG_G(exec_len)); backup_phpdbg_compile = zend_string_alloc(data->len + 2, 1); + GC_MAKE_PERSISTENT_LOCAL(backup_phpdbg_compile); sprintf(ZSTR_VAL(backup_phpdbg_compile), "?>%.*s", (int) data->len, data->buf); } @@ -2152,8 +2151,8 @@ phpdbg_out: } { - php_stream_wrapper *wrapper = zend_hash_str_find_ptr(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php")); - wrapper->wops->stream_opener = PHPDBG_G(orig_url_wrap_php); + zval *zv = zend_hash_str_find(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php")); + Z_PTR_P(zv) = (void*)PHPDBG_G(orig_url_wrap_php); } zend_hash_destroy(&PHPDBG_G(file_sources)); diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index e22a968d96..72501bffb4 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -76,10 +76,10 @@ #undef zend_hash_str_add #ifdef PHP_WIN32 #define zend_hash_str_add(...) \ - _zend_hash_str_add(__VA_ARGS__ ZEND_FILE_LINE_CC) + zend_hash_str_add(__VA_ARGS__) #else #define zend_hash_str_add_tmp(ht, key, len, pData) \ - _zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC) + zend_hash_str_add(ht, key, len, pData) #define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__) #endif @@ -310,7 +310,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) zend_bool last_was_newline; /* check if we don't need to output a newline upon next phpdbg_error or phpdbg_notice */ FILE *stdin_file; /* FILE pointer to stdin source file */ - php_stream *(*orig_url_wrap_php)(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); + const php_stream_wrapper *orig_url_wrap_php; char input_buffer[PHPDBG_MAX_CMD]; /* stdin input buffer */ int input_buflen; /* length of stdin input buffer */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index b9250fda3f..c0053005ad 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -137,7 +137,7 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */ switch (brake->type) { case PHPDBG_BREAK_FILE: { - zend_string *filename = php_addcslashes(zend_string_init(((phpdbg_breakfile_t*)brake)->filename, strlen(((phpdbg_breakfile_t*)brake)->filename), 0), 1, "\\\"\n", 3); + zend_string *filename = php_addcslashes_str(((phpdbg_breakfile_t*)brake)->filename, strlen(((phpdbg_breakfile_t*)brake)->filename), "\\\"\n", 3); phpdbg_asprintf(&new_str, "%sbreak \"%s\":%lu\n", *str, ZSTR_VAL(filename), @@ -174,7 +174,7 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */ } break; case PHPDBG_BREAK_FILE_OPLINE: { - zend_string *filename = php_addcslashes(zend_string_init(((phpdbg_breakopline_t*)brake)->class_name, strlen(((phpdbg_breakopline_t*)brake)->class_name), 0), 1, "\\\"\n", 3); + zend_string *filename = php_addcslashes_str(((phpdbg_breakopline_t*)brake)->class_name, strlen(((phpdbg_breakopline_t*)brake)->class_name), "\\\"\n", 3); phpdbg_asprintf(&new_str, "%sbreak \"%s\":#%llu\n", *str, ZSTR_VAL(filename), @@ -224,7 +224,7 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */ break; case FILE_PARAM: { - zend_string *filename = php_addcslashes(zend_string_init(conditional->param.file.name, strlen(conditional->param.file.name), 0), 1, "\\\"\n", 3); + zend_string *filename = php_addcslashes_str(conditional->param.file.name, strlen(conditional->param.file.name), "\\\"\n", 3); phpdbg_asprintf(&new_str, "%sbreak at \"%s\":%lu if %s\n", *str, ZSTR_VAL(filename), conditional->param.file.line, @@ -888,7 +888,7 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co new_break.ops = zend_compile_string(&pv, "Conditional Breakpoint Code"); - zval_dtor(&pv); + zval_ptr_dtor_str(&pv); if (new_break.ops) { brake = zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash, &new_break, sizeof(phpdbg_breakcond_t)); diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index 7cdedcb497..2065277dfe 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -314,7 +314,7 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */ phpdbg_writeln("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_P(file), Z_LVAL_P(line)); phpdbg_xml("</backtrace>"); - zval_dtor(&zbacktrace); + zval_ptr_dtor_nogc(&zbacktrace); zend_string_release(Z_STR(startfile)); PHPDBG_OUTPUT_BACKUP_RESTORE(); diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c index c0c9ac156a..146a45681b 100644 --- a/sapi/phpdbg/phpdbg_info.c +++ b/sapi/phpdbg/phpdbg_info.c @@ -105,7 +105,7 @@ PHPDBG_INFO(constants) /* {{{ */ if (EG(zend_constants)) { phpdbg_try_access { ZEND_HASH_FOREACH_PTR(EG(zend_constants), data) { - if (data->module_number == PHP_USER_CONSTANT) { + if (ZEND_CONSTANT_MODULE_NUMBER(data) == PHP_USER_CONSTANT) { zend_hash_update_ptr(&consts, data->name, data); } } ZEND_HASH_FOREACH_END(); diff --git a/sapi/phpdbg/phpdbg_lexer.c b/sapi/phpdbg/phpdbg_lexer.c index 55bc3275ac..2ab0b5ac67 100644 --- a/sapi/phpdbg/phpdbg_lexer.c +++ b/sapi/phpdbg/phpdbg_lexer.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.16 */ +/* Generated by re2c 1.0.3 */ #line 1 "sapi/phpdbg/phpdbg_lexer.l" /* * phpdbg_lexer.l @@ -82,251 +82,6 @@ restart: } } /* *********************************** */ -yyc_INITIAL: - { - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 128, 0, 0, 0, 128, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 128, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }; - YYDEBUG(1, *YYCURSOR); - YYFILL(4); - yych = *YYCURSOR; - if (yych <= 'E') { - if (yych <= '\r') { - if (yych == '\t') goto yy5; - if (yych >= '\r') goto yy5; - } else { - if (yych == ' ') goto yy6; - if (yych >= 'E') goto yy9; - } - } else { - if (yych <= 'd') { - if (yych <= 'Q') goto yy3; - if (yych <= 'R') goto yy10; - if (yych <= 'S') goto yy11; - } else { - if (yych <= 'q') { - if (yych <= 'e') goto yy9; - } else { - if (yych <= 'r') goto yy12; - if (yych <= 's') goto yy11; - } - } - } -yy3: - YYDEBUG(3, *YYCURSOR); - ++YYCURSOR; -yy4: - YYDEBUG(4, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 206 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(NORMAL); - - YYCURSOR = LEX(text); - goto restart; -} -#line 160 "sapi/phpdbg/phpdbg_lexer.c" -yy5: - YYDEBUG(5, *YYCURSOR); - yych = *++YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy6; - } - goto yy4; -yy6: - YYDEBUG(6, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(7, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy6; - } - YYDEBUG(8, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 175 "sapi/phpdbg/phpdbg_lexer.l" - { - /* ignore whitespace */ - - goto restart; -} -#line 185 "sapi/phpdbg/phpdbg_lexer.c" -yy9: - YYDEBUG(9, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'V') goto yy13; - if (yych == 'v') goto yy13; - goto yy4; -yy10: - YYDEBUG(10, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy15; - if (yych == 'u') goto yy15; - goto yy4; -yy11: - YYDEBUG(11, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'H') goto yy16; - if (yych == 'h') goto yy16; - goto yy4; -yy12: - YYDEBUG(12, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x1F) { - if (yych <= '\t') { - if (yych <= 0x08) goto yy4; - goto yy17; - } else { - if (yych == '\r') goto yy17; - goto yy4; - } - } else { - if (yych <= 'U') { - if (yych <= ' ') goto yy17; - if (yych <= 'T') goto yy4; - goto yy15; - } else { - if (yych == 'u') goto yy15; - goto yy4; - } - } -yy13: - YYDEBUG(13, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy20; - } else { - if (yych <= '\r') goto yy20; - if (yych == ' ') goto yy20; - } -yy14: - YYDEBUG(14, *YYCURSOR); - YYCURSOR = YYMARKER; - goto yy4; -yy15: - YYDEBUG(15, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy23; - if (yych == 'n') goto yy23; - goto yy14; -yy16: - YYDEBUG(16, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy24; - goto yy14; - } else { - if (yych <= '\r') goto yy24; - if (yych == ' ') goto yy24; - goto yy14; - } -yy17: - YYDEBUG(17, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(18, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy17; - } else { - if (yych <= '\r') goto yy17; - if (yych == ' ') goto yy17; - } - YYDEBUG(19, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 193 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(PRE_RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_RUN; -} -#line 275 "sapi/phpdbg/phpdbg_lexer.c" -yy20: - YYDEBUG(20, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(21, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy20; - } else { - if (yych <= '\r') goto yy20; - if (yych == ' ') goto yy20; - } - YYDEBUG(22, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 181 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(PRE_RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_EVAL; -} -#line 296 "sapi/phpdbg/phpdbg_lexer.c" -yy23: - YYDEBUG(23, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy17; - goto yy14; - } else { - if (yych <= '\r') goto yy17; - if (yych == ' ') goto yy17; - goto yy14; - } -yy24: - YYDEBUG(24, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(25, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy24; - } else { - if (yych <= '\r') goto yy24; - if (yych == ' ') goto yy24; - } - YYDEBUG(26, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 187 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(PRE_RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_SHELL; -} -#line 328 "sapi/phpdbg/phpdbg_lexer.c" - } -/* *********************************** */ yyc_NORMAL: { static const unsigned char yybm[] = { @@ -397,20 +152,20 @@ yyc_NORMAL: 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; - YYDEBUG(27, *YYCURSOR); + YYDEBUG(1, *YYCURSOR); YYFILL(11); yych = *YYCURSOR; if (yybm[256+yych] & 128) { - goto yy34; + goto yy8; } switch (yych) { case 0x00: case '\t': - case '\n': goto yy29; - case '"': goto yy37; - case '#': goto yy39; - case '\'': goto yy41; - case '-': goto yy42; + case '\n': goto yy3; + case '"': goto yy11; + case '#': goto yy13; + case '\'': goto yy15; + case '-': goto yy16; case '.': case '1': case '2': @@ -420,56 +175,56 @@ yyc_NORMAL: case '6': case '7': case '8': - case '9': goto yy43; - case '0': goto yy46; - case ':': goto yy47; + case '9': goto yy17; + case '0': goto yy20; + case ':': goto yy21; case 'D': - case 'd': goto yy48; + case 'd': goto yy22; case 'E': - case 'e': goto yy49; + case 'e': goto yy23; case 'F': - case 'f': goto yy50; + case 'f': goto yy24; case 'I': - case 'i': goto yy51; + case 'i': goto yy25; case 'N': - case 'n': goto yy52; + case 'n': goto yy26; case 'O': - case 'o': goto yy53; + case 'o': goto yy27; case 'T': - case 't': goto yy54; + case 't': goto yy28; case 'Y': - case 'y': goto yy55; - case 'Z': goto yy56; - case 'z': goto yy57; - default: goto yy31; + case 'y': goto yy29; + case 'Z': goto yy30; + case 'z': goto yy31; + default: goto yy5; } -yy29: - YYDEBUG(29, *YYCURSOR); +yy3: + YYDEBUG(3, *YYCURSOR); ++YYCURSOR; - YYDEBUG(30, *YYCURSOR); + YYDEBUG(4, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 89 "sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 456 "sapi/phpdbg/phpdbg_lexer.c" -yy31: - YYDEBUG(31, *YYCURSOR); +#line 211 "sapi/phpdbg/phpdbg_lexer.c" +yy5: + YYDEBUG(5, *YYCURSOR); yyaccept = 0; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy32: - YYDEBUG(32, *YYCURSOR); +yy6: + YYDEBUG(6, *YYCURSOR); if (yybm[256+yych] & 64) { - goto yy31; + goto yy5; } - if (yych <= ' ') goto yy33; - if (yych == '#') goto yy33; - if (yych <= '\'') goto yy58; - goto yy60; -yy33: - YYDEBUG(33, *YYCURSOR); + if (yych <= ' ') goto yy7; + if (yych == '#') goto yy7; + if (yych <= '\'') goto yy32; + goto yy34; +yy7: + YYDEBUG(7, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 161 "sapi/phpdbg/phpdbg_lexer.l" { @@ -478,17 +233,17 @@ yy33: yylval->len = yyleng; return T_ID; } -#line 482 "sapi/phpdbg/phpdbg_lexer.c" -yy34: - YYDEBUG(34, *YYCURSOR); +#line 237 "sapi/phpdbg/phpdbg_lexer.c" +yy8: + YYDEBUG(8, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(35, *YYCURSOR); + YYDEBUG(9, *YYCURSOR); if (yybm[256+yych] & 128) { - goto yy34; + goto yy8; } - YYDEBUG(36, *YYCURSOR); + YYDEBUG(10, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 175 "sapi/phpdbg/phpdbg_lexer.l" { @@ -496,108 +251,114 @@ yy34: goto restart; } -#line 500 "sapi/phpdbg/phpdbg_lexer.c" -yy37: - YYDEBUG(37, *YYCURSOR); +#line 255 "sapi/phpdbg/phpdbg_lexer.c" +yy11: + YYDEBUG(11, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '"') goto yy58; - goto yy62; -yy38: - YYDEBUG(38, *YYCURSOR); + if (yych == '"') goto yy32; + goto yy36; +yy12: + YYDEBUG(12, *YYCURSOR); YYCURSOR = YYMARKER; if (yyaccept <= 3) { if (yyaccept <= 1) { if (yyaccept == 0) { - goto yy33; + goto yy7; } else { - goto yy40; + goto yy14; } } else { if (yyaccept == 2) { - goto yy45; + goto yy19; } else { - goto yy109; + goto yy83; } } } else { if (yyaccept <= 5) { if (yyaccept == 4) { - goto yy112; + goto yy86; } else { - goto yy128; + goto yy102; } } else { - goto yy145; + goto yy119; } } -yy39: - YYDEBUG(39, *YYCURSOR); +yy13: + YYDEBUG(13, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - YYCTXMARKER = YYCURSOR; if (yych <= '.') { - if (yych <= ',') goto yy40; - if (yych <= '-') goto yy67; - goto yy68; + if (yych <= ',') goto yy14; + if (yych <= '-') { + YYCTXMARKER = YYCURSOR; + goto yy41; + } + YYCTXMARKER = YYCURSOR; + goto yy42; } else { - if (yych <= '/') goto yy40; - if (yych <= '9') goto yy68; + if (yych <= '/') goto yy14; + if (yych <= '9') { + YYCTXMARKER = YYCURSOR; + goto yy42; + } } -yy40: - YYDEBUG(40, *YYCURSOR); +yy14: + YYDEBUG(14, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 110 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(INITIAL); return T_SEPARATOR; } -#line 555 "sapi/phpdbg/phpdbg_lexer.c" -yy41: - YYDEBUG(41, *YYCURSOR); +#line 316 "sapi/phpdbg/phpdbg_lexer.c" +yy15: + YYDEBUG(15, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '\'') goto yy58; - goto yy72; -yy42: - YYDEBUG(42, *YYCURSOR); + if (yych == '\'') goto yy32; + goto yy46; +yy16: + YYDEBUG(16, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 1) { - goto yy43; + goto yy17; } - if (yych == 'r') goto yy77; - goto yy32; -yy43: - YYDEBUG(43, *YYCURSOR); + if (yych == 'r') goto yy51; + goto yy6; +yy17: + YYDEBUG(17, *YYCURSOR); yyaccept = 2; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(44, *YYCURSOR); + YYDEBUG(18, *YYCURSOR); if (yybm[0+yych] & 1) { - goto yy43; + goto yy17; } if (yych <= ' ') { if (yych <= '\n') { - if (yych <= 0x00) goto yy45; - if (yych <= 0x08) goto yy31; + if (yych <= 0x00) goto yy19; + if (yych <= 0x08) goto yy5; } else { - if (yych == '\r') goto yy45; - if (yych <= 0x1F) goto yy31; + if (yych == '\r') goto yy19; + if (yych <= 0x1F) goto yy5; } } else { if (yych <= '&') { - if (yych <= '!') goto yy31; - if (yych <= '"') goto yy58; - if (yych >= '$') goto yy31; + if (yych <= '!') goto yy5; + if (yych <= '"') goto yy32; + if (yych >= '$') goto yy5; } else { - if (yych <= '\'') goto yy58; - if (yych <= '/') goto yy31; - if (yych <= ':') goto yy60; - goto yy31; + if (yych <= '\'') goto yy32; + if (yych <= '/') goto yy5; + if (yych <= ':') goto yy34; + goto yy5; } } -yy45: - YYDEBUG(45, *YYCURSOR); +yy19: + YYDEBUG(19, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 142 "sapi/phpdbg/phpdbg_lexer.l" { @@ -605,598 +366,595 @@ yy45: yylval->num = atoi(yytext); return T_DIGITS; } -#line 609 "sapi/phpdbg/phpdbg_lexer.c" -yy46: - YYDEBUG(46, *YYCURSOR); +#line 370 "sapi/phpdbg/phpdbg_lexer.c" +yy20: + YYDEBUG(20, *YYCURSOR); yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 1) { - goto yy43; + goto yy17; } if (yych <= 0x1F) { if (yych <= '\n') { - if (yych <= 0x00) goto yy45; - if (yych <= 0x08) goto yy32; - goto yy45; + if (yych <= 0x00) goto yy19; + if (yych <= 0x08) goto yy6; + goto yy19; } else { - if (yych == '\r') goto yy45; - goto yy32; + if (yych == '\r') goto yy19; + goto yy6; } } else { if (yych <= '#') { - if (yych <= ' ') goto yy45; - if (yych <= '"') goto yy32; - goto yy45; + if (yych <= ' ') goto yy19; + if (yych <= '"') goto yy6; + goto yy19; } else { - if (yych == 'x') goto yy78; - goto yy32; + if (yych == 'x') goto yy52; + goto yy6; } } -yy47: - YYDEBUG(47, *YYCURSOR); +yy21: + YYDEBUG(21, *YYCURSOR); yych = *++YYCURSOR; - YYCTXMARKER = YYCURSOR; - if (yych == ':') goto yy81; - if (yych == '\\') goto yy83; - goto yy79; -yy48: - YYDEBUG(48, *YYCURSOR); + if (yych == ':') goto yy55; + if (yych == '\\') goto yy57; + goto yy53; +yy22: + YYDEBUG(22, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'I') goto yy85; - if (yych == 'i') goto yy85; - goto yy32; -yy49: - YYDEBUG(49, *YYCURSOR); + if (yych == 'I') goto yy59; + if (yych == 'i') goto yy59; + goto yy6; +yy23: + YYDEBUG(23, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'N') goto yy86; - if (yych == 'n') goto yy86; - goto yy32; -yy50: - YYDEBUG(50, *YYCURSOR); + if (yych == 'N') goto yy60; + if (yych == 'n') goto yy60; + goto yy6; +yy24: + YYDEBUG(24, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy87; - if (yych == 'a') goto yy87; - goto yy32; -yy51: - YYDEBUG(51, *YYCURSOR); + if (yych == 'A') goto yy61; + if (yych == 'a') goto yy61; + goto yy6; +yy25: + YYDEBUG(25, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy88; - if (yych == 'f') goto yy88; - goto yy32; -yy52: - YYDEBUG(52, *YYCURSOR); + if (yych == 'F') goto yy62; + if (yych == 'f') goto yy62; + goto yy6; +yy26: + YYDEBUG(26, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'O') goto yy89; - if (yych == 'o') goto yy89; - goto yy32; -yy53: - YYDEBUG(53, *YYCURSOR); + if (yych == 'O') goto yy63; + if (yych == 'o') goto yy63; + goto yy6; +yy27: + YYDEBUG(27, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'N') { - if (yych == 'F') goto yy90; - if (yych <= 'M') goto yy32; - goto yy91; + if (yych == 'F') goto yy64; + if (yych <= 'M') goto yy6; + goto yy65; } else { if (yych <= 'f') { - if (yych <= 'e') goto yy32; - goto yy90; + if (yych <= 'e') goto yy6; + goto yy64; } else { - if (yych == 'n') goto yy91; - goto yy32; + if (yych == 'n') goto yy65; + goto yy6; } } -yy54: - YYDEBUG(54, *YYCURSOR); +yy28: + YYDEBUG(28, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'R') goto yy92; - if (yych == 'r') goto yy92; - goto yy32; -yy55: - YYDEBUG(55, *YYCURSOR); + if (yych == 'R') goto yy66; + if (yych == 'r') goto yy66; + goto yy6; +yy29: + YYDEBUG(29, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy93; - if (yych == 'e') goto yy93; - goto yy32; -yy56: - YYDEBUG(56, *YYCURSOR); + if (yych == 'E') goto yy67; + if (yych == 'e') goto yy67; + goto yy6; +yy30: + YYDEBUG(30, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy94; - goto yy32; -yy57: - YYDEBUG(57, *YYCURSOR); + if (yych == 'E') goto yy68; + goto yy6; +yy31: + YYDEBUG(31, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy95; - goto yy32; -yy58: - YYDEBUG(58, *YYCURSOR); + if (yych == 'e') goto yy69; + goto yy6; +yy32: + YYDEBUG(32, *YYCURSOR); ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; -yy59: - YYDEBUG(59, *YYCURSOR); +yy33: + YYDEBUG(33, *YYCURSOR); if (yybm[0+yych] & 2) { - goto yy58; + goto yy32; } - if (yych <= '#') goto yy38; - goto yy96; -yy60: - YYDEBUG(60, *YYCURSOR); + if (yych <= '#') goto yy12; + goto yy70; +yy34: + YYDEBUG(34, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy97; - if (yych == '\\') goto yy83; - goto yy38; -yy61: - YYDEBUG(61, *YYCURSOR); + if (yych == '/') goto yy71; + if (yych == '\\') goto yy57; + goto yy12; +yy35: + YYDEBUG(35, *YYCURSOR); ++YYCURSOR; YYFILL(4); yych = *YYCURSOR; -yy62: - YYDEBUG(62, *YYCURSOR); +yy36: + YYDEBUG(36, *YYCURSOR); if (yybm[0+yych] & 4) { - goto yy61; + goto yy35; } if (yych <= ' ') { - if (yych <= 0x00) goto yy38; - if (yych == '\n') goto yy38; + if (yych <= 0x00) goto yy12; + if (yych == '\n') goto yy12; } else { - if (yych <= '"') goto yy98; - if (yych <= '#') goto yy63; - if (yych <= ':') goto yy65; - goto yy66; + if (yych <= '"') goto yy72; + if (yych <= '#') goto yy37; + if (yych <= ':') goto yy39; + goto yy40; } -yy63: - YYDEBUG(63, *YYCURSOR); +yy37: + YYDEBUG(37, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy64: - YYDEBUG(64, *YYCURSOR); +yy38: + YYDEBUG(38, *YYCURSOR); if (yybm[0+yych] & 8) { - goto yy63; + goto yy37; } - if (yych <= '\n') goto yy38; - if (yych <= '"') goto yy99; - goto yy100; -yy65: - YYDEBUG(65, *YYCURSOR); + if (yych <= '\n') goto yy12; + if (yych <= '"') goto yy73; + goto yy74; +yy39: + YYDEBUG(39, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy101; - goto yy64; -yy66: - YYDEBUG(66, *YYCURSOR); + if (yych == '/') goto yy75; + goto yy38; +yy40: + YYDEBUG(40, *YYCURSOR); ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; if (yych <= ' ') { if (yych <= '\n') { - if (yych <= 0x00) goto yy38; - if (yych <= 0x08) goto yy58; - goto yy38; + if (yych <= 0x00) goto yy12; + if (yych <= 0x08) goto yy32; + goto yy12; } else { - if (yych == '\r') goto yy38; - if (yych <= 0x1F) goto yy58; - goto yy38; + if (yych == '\r') goto yy12; + if (yych <= 0x1F) goto yy32; + goto yy12; } } else { if (yych <= '9') { - if (yych <= '!') goto yy58; - if (yych <= '"') goto yy61; - if (yych <= '#') goto yy38; - goto yy58; + if (yych <= '!') goto yy32; + if (yych <= '"') goto yy35; + if (yych <= '#') goto yy12; + goto yy32; } else { - if (yych <= ':') goto yy96; - if (yych == '\\') goto yy61; - goto yy58; + if (yych <= ':') goto yy70; + if (yych == '\\') goto yy35; + goto yy32; } } -yy67: - YYDEBUG(67, *YYCURSOR); +yy41: + YYDEBUG(41, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '.') goto yy68; - if (yych <= '/') goto yy38; - if (yych >= ':') goto yy38; -yy68: - YYDEBUG(68, *YYCURSOR); + if (yych == '.') goto yy42; + if (yych <= '/') goto yy12; + if (yych >= ':') goto yy12; +yy42: + YYDEBUG(42, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(69, *YYCURSOR); - if (yych == '.') goto yy68; - if (yych <= '/') goto yy70; - if (yych <= '9') goto yy68; -yy70: - YYDEBUG(70, *YYCURSOR); + YYDEBUG(43, *YYCURSOR); + if (yych == '.') goto yy42; + if (yych <= '/') goto yy44; + if (yych <= '9') goto yy42; +yy44: + YYDEBUG(44, *YYCURSOR); YYCURSOR = YYCTXMARKER; yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 106 "sapi/phpdbg/phpdbg_lexer.l" { return T_POUND; } -#line 826 "sapi/phpdbg/phpdbg_lexer.c" -yy71: - YYDEBUG(71, *YYCURSOR); +#line 586 "sapi/phpdbg/phpdbg_lexer.c" +yy45: + YYDEBUG(45, *YYCURSOR); ++YYCURSOR; YYFILL(4); yych = *YYCURSOR; -yy72: - YYDEBUG(72, *YYCURSOR); +yy46: + YYDEBUG(46, *YYCURSOR); if (yybm[0+yych] & 16) { - goto yy71; + goto yy45; } if (yych <= '\n') { - if (yych <= 0x00) goto yy38; - if (yych >= '\n') goto yy38; + if (yych <= 0x00) goto yy12; + if (yych >= '\n') goto yy12; } else { - if (yych <= '#') goto yy73; - if (yych <= '\'') goto yy98; - if (yych <= ':') goto yy75; - goto yy76; + if (yych <= '#') goto yy47; + if (yych <= '\'') goto yy72; + if (yych <= ':') goto yy49; + goto yy50; } -yy73: - YYDEBUG(73, *YYCURSOR); +yy47: + YYDEBUG(47, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; -yy74: - YYDEBUG(74, *YYCURSOR); +yy48: + YYDEBUG(48, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy73; + goto yy47; } - if (yych <= '\n') goto yy38; - if (yych <= '\'') goto yy99; - goto yy102; -yy75: - YYDEBUG(75, *YYCURSOR); + if (yych <= '\n') goto yy12; + if (yych <= '\'') goto yy73; + goto yy76; +yy49: + YYDEBUG(49, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy103; - goto yy74; -yy76: - YYDEBUG(76, *YYCURSOR); + if (yych == '/') goto yy77; + goto yy48; +yy50: + YYDEBUG(50, *YYCURSOR); ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; if (yych <= '"') { if (yych <= '\f') { - if (yych <= 0x00) goto yy38; - if (yych <= 0x08) goto yy58; - if (yych <= '\n') goto yy38; - goto yy58; + if (yych <= 0x00) goto yy12; + if (yych <= 0x08) goto yy32; + if (yych <= '\n') goto yy12; + goto yy32; } else { - if (yych <= '\r') goto yy38; - if (yych == ' ') goto yy38; - goto yy58; + if (yych <= '\r') goto yy12; + if (yych == ' ') goto yy12; + goto yy32; } } else { if (yych <= '9') { - if (yych <= '#') goto yy38; - if (yych == '\'') goto yy71; - goto yy58; + if (yych <= '#') goto yy12; + if (yych == '\'') goto yy45; + goto yy32; } else { - if (yych <= ':') goto yy96; - if (yych == '\\') goto yy71; - goto yy58; + if (yych <= ':') goto yy70; + if (yych == '\\') goto yy45; + goto yy32; } } -yy77: - YYDEBUG(77, *YYCURSOR); +yy51: + YYDEBUG(51, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= ' ') { if (yych <= '\f') { - if (yych == '\t') goto yy104; - goto yy32; + if (yych == '\t') goto yy78; + goto yy6; } else { - if (yych <= '\r') goto yy104; - if (yych <= 0x1F) goto yy32; - goto yy104; + if (yych <= '\r') goto yy78; + if (yych <= 0x1F) goto yy6; + goto yy78; } } else { if (yych <= '.') { - if (yych <= ',') goto yy32; - if (yych <= '-') goto yy106; - goto yy107; + if (yych <= ',') goto yy6; + if (yych <= '-') goto yy80; + goto yy81; } else { - if (yych <= '/') goto yy32; - if (yych <= '9') goto yy107; - goto yy32; + if (yych <= '/') goto yy6; + if (yych <= '9') goto yy81; + goto yy6; } } -yy78: - YYDEBUG(78, *YYCURSOR); +yy52: + YYDEBUG(52, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 64) { - goto yy110; + goto yy84; } - goto yy32; -yy79: - YYDEBUG(79, *YYCURSOR); + goto yy6; +yy53: + YYDEBUG(53, *YYCURSOR); ++YYCURSOR; - YYDEBUG(80, *YYCURSOR); - YYCURSOR = YYCTXMARKER; + YYDEBUG(54, *YYCURSOR); + YYCURSOR -= 1; yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 119 "sapi/phpdbg/phpdbg_lexer.l" { return T_COLON; } -#line 933 "sapi/phpdbg/phpdbg_lexer.c" -yy81: - YYDEBUG(81, *YYCURSOR); +#line 693 "sapi/phpdbg/phpdbg_lexer.c" +yy55: + YYDEBUG(55, *YYCURSOR); ++YYCURSOR; - YYDEBUG(82, *YYCURSOR); + YYDEBUG(56, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 115 "sapi/phpdbg/phpdbg_lexer.l" { return T_DCOLON; } -#line 943 "sapi/phpdbg/phpdbg_lexer.c" -yy83: - YYDEBUG(83, *YYCURSOR); +#line 703 "sapi/phpdbg/phpdbg_lexer.c" +yy57: + YYDEBUG(57, *YYCURSOR); yyaccept = 0; YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(84, *YYCURSOR); + YYDEBUG(58, *YYCURSOR); if (yych <= ' ') { if (yych <= '\n') { - if (yych <= 0x00) goto yy33; - if (yych <= 0x08) goto yy83; - goto yy33; + if (yych <= 0x00) goto yy7; + if (yych <= 0x08) goto yy57; + goto yy7; } else { - if (yych == '\r') goto yy33; - if (yych <= 0x1F) goto yy83; - goto yy33; + if (yych == '\r') goto yy7; + if (yych <= 0x1F) goto yy57; + goto yy7; } } else { if (yych <= '&') { - if (yych <= '!') goto yy83; - if (yych <= '#') goto yy33; - goto yy83; + if (yych <= '!') goto yy57; + if (yych <= '#') goto yy7; + goto yy57; } else { - if (yych <= '\'') goto yy33; - if (yych == ':') goto yy113; - goto yy83; + if (yych <= '\'') goto yy7; + if (yych == ':') goto yy87; + goto yy57; } } -yy85: - YYDEBUG(85, *YYCURSOR); +yy59: + YYDEBUG(59, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy114; - if (yych == 's') goto yy114; - goto yy32; -yy86: - YYDEBUG(86, *YYCURSOR); + if (yych == 'S') goto yy88; + if (yych == 's') goto yy88; + goto yy6; +yy60: + YYDEBUG(60, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy115; - if (yych == 'a') goto yy115; - goto yy32; -yy87: - YYDEBUG(87, *YYCURSOR); + if (yych == 'A') goto yy89; + if (yych == 'a') goto yy89; + goto yy6; +yy61: + YYDEBUG(61, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy116; - if (yych == 'l') goto yy116; - goto yy32; -yy88: - YYDEBUG(88, *YYCURSOR); + if (yych == 'L') goto yy90; + if (yych == 'l') goto yy90; + goto yy6; +yy62: + YYDEBUG(62, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '\f') { - if (yych == '\t') goto yy117; - goto yy32; + if (yych == '\t') goto yy91; + goto yy6; } else { - if (yych <= '\r') goto yy117; - if (yych == ' ') goto yy117; - goto yy32; + if (yych <= '\r') goto yy91; + if (yych == ' ') goto yy91; + goto yy6; } -yy89: - YYDEBUG(89, *YYCURSOR); +yy63: + YYDEBUG(63, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - YYCTXMARKER = YYCURSOR; if (yych <= '\f') { - if (yych <= 0x00) goto yy120; - if (yych <= 0x08) goto yy32; - if (yych <= '\n') goto yy120; - goto yy32; + if (yych <= 0x00) goto yy94; + if (yych <= 0x08) goto yy6; + if (yych <= '\n') goto yy94; + goto yy6; } else { - if (yych <= '\r') goto yy120; - if (yych == ' ') goto yy120; - goto yy32; + if (yych <= '\r') goto yy94; + if (yych == ' ') goto yy94; + goto yy6; } -yy90: - YYDEBUG(90, *YYCURSOR); +yy64: + YYDEBUG(64, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy89; - if (yych == 'f') goto yy89; - goto yy32; -yy91: - YYDEBUG(91, *YYCURSOR); + if (yych == 'F') goto yy63; + if (yych == 'f') goto yy63; + goto yy6; +yy65: + YYDEBUG(65, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - YYCTXMARKER = YYCURSOR; if (yych <= '\f') { - if (yych <= 0x00) goto yy122; - if (yych <= 0x08) goto yy32; - if (yych <= '\n') goto yy122; - goto yy32; + if (yych <= 0x00) goto yy96; + if (yych <= 0x08) goto yy6; + if (yych <= '\n') goto yy96; + goto yy6; } else { - if (yych <= '\r') goto yy122; - if (yych == ' ') goto yy122; - goto yy32; + if (yych <= '\r') goto yy96; + if (yych == ' ') goto yy96; + goto yy6; } -yy92: - YYDEBUG(92, *YYCURSOR); +yy66: + YYDEBUG(66, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy124; - if (yych == 'u') goto yy124; - goto yy32; -yy93: - YYDEBUG(93, *YYCURSOR); + if (yych == 'U') goto yy98; + if (yych == 'u') goto yy98; + goto yy6; +yy67: + YYDEBUG(67, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy91; - if (yych == 's') goto yy91; - goto yy32; -yy94: - YYDEBUG(94, *YYCURSOR); + if (yych == 'S') goto yy65; + if (yych == 's') goto yy65; + goto yy6; +yy68: + YYDEBUG(68, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'N') goto yy125; - goto yy32; -yy95: - YYDEBUG(95, *YYCURSOR); + if (yych == 'N') goto yy99; + goto yy6; +yy69: + YYDEBUG(69, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'n') goto yy126; - goto yy32; -yy96: - YYDEBUG(96, *YYCURSOR); + if (yych == 'n') goto yy100; + goto yy6; +yy70: + YYDEBUG(70, *YYCURSOR); yych = *++YYCURSOR; - if (yych != '/') goto yy38; -yy97: - YYDEBUG(97, *YYCURSOR); + if (yych != '/') goto yy12; +yy71: + YYDEBUG(71, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy127; - goto yy38; -yy98: - YYDEBUG(98, *YYCURSOR); + if (yych == '/') goto yy101; + goto yy12; +yy72: + YYDEBUG(72, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '\r') { if (yych <= 0x08) { - if (yych <= 0x00) goto yy33; - goto yy59; - } else { - if (yych <= '\n') goto yy33; - if (yych <= '\f') goto yy59; + if (yych <= 0x00) goto yy7; goto yy33; + } else { + if (yych <= '\n') goto yy7; + if (yych <= '\f') goto yy33; + goto yy7; } } else { if (yych <= ' ') { - if (yych <= 0x1F) goto yy59; - goto yy33; + if (yych <= 0x1F) goto yy33; + goto yy7; } else { - if (yych == '#') goto yy33; - goto yy59; + if (yych == '#') goto yy7; + goto yy33; } } -yy99: - YYDEBUG(99, *YYCURSOR); - yych = *++YYCURSOR; - goto yy33; -yy100: - YYDEBUG(100, *YYCURSOR); +yy73: + YYDEBUG(73, *YYCURSOR); + ++YYCURSOR; + goto yy7; +yy74: + YYDEBUG(74, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - if (yych == '"') goto yy63; - if (yych == '\\') goto yy63; - goto yy38; -yy101: - YYDEBUG(101, *YYCURSOR); + if (yych == '"') goto yy37; + if (yych == '\\') goto yy37; + goto yy12; +yy75: + YYDEBUG(75, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy129; - goto yy64; -yy102: - YYDEBUG(102, *YYCURSOR); + if (yych == '/') goto yy103; + goto yy38; +yy76: + YYDEBUG(76, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - if (yych == '\'') goto yy73; - if (yych == '\\') goto yy73; - goto yy38; -yy103: - YYDEBUG(103, *YYCURSOR); + if (yych == '\'') goto yy47; + if (yych == '\\') goto yy47; + goto yy12; +yy77: + YYDEBUG(77, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '/') goto yy130; - goto yy74; -yy104: - YYDEBUG(104, *YYCURSOR); + if (yych == '/') goto yy104; + goto yy48; +yy78: + YYDEBUG(78, *YYCURSOR); ++YYCURSOR; YYFILL(2); yych = *YYCURSOR; - YYDEBUG(105, *YYCURSOR); + YYDEBUG(79, *YYCURSOR); if (yych <= ' ') { if (yych <= '\f') { - if (yych == '\t') goto yy104; - goto yy38; + if (yych == '\t') goto yy78; + goto yy12; } else { - if (yych <= '\r') goto yy104; - if (yych <= 0x1F) goto yy38; - goto yy104; + if (yych <= '\r') goto yy78; + if (yych <= 0x1F) goto yy12; + goto yy78; } } else { if (yych <= '.') { - if (yych <= ',') goto yy38; - if (yych <= '-') goto yy131; - goto yy132; + if (yych <= ',') goto yy12; + if (yych <= '-') goto yy105; + goto yy106; } else { - if (yych <= '/') goto yy38; - if (yych <= '9') goto yy132; - goto yy38; + if (yych <= '/') goto yy12; + if (yych <= '9') goto yy106; + goto yy12; } } -yy106: - YYDEBUG(106, *YYCURSOR); +yy80: + YYDEBUG(80, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '.') goto yy107; - if (yych <= '/') goto yy32; - if (yych >= ':') goto yy32; -yy107: - YYDEBUG(107, *YYCURSOR); + if (yych == '.') goto yy81; + if (yych <= '/') goto yy6; + if (yych >= ':') goto yy6; +yy81: + YYDEBUG(81, *YYCURSOR); yyaccept = 3; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(108, *YYCURSOR); + YYDEBUG(82, *YYCURSOR); if (yych <= '"') { if (yych <= '\f') { - if (yych <= 0x00) goto yy109; - if (yych <= 0x08) goto yy31; - if (yych >= '\v') goto yy31; + if (yych <= 0x00) goto yy83; + if (yych <= 0x08) goto yy5; + if (yych >= '\v') goto yy5; } else { if (yych <= 0x1F) { - if (yych >= 0x0E) goto yy31; + if (yych >= 0x0E) goto yy5; } else { - if (yych <= ' ') goto yy109; - if (yych <= '!') goto yy31; - goto yy58; + if (yych <= ' ') goto yy83; + if (yych <= '!') goto yy5; + goto yy32; } } } else { if (yych <= '-') { - if (yych <= '#') goto yy109; - if (yych == '\'') goto yy58; - goto yy31; + if (yych <= '#') goto yy83; + if (yych == '\'') goto yy32; + goto yy5; } else { if (yych <= '/') { - if (yych <= '.') goto yy107; - goto yy31; + if (yych <= '.') goto yy81; + goto yy5; } else { - if (yych <= '9') goto yy107; - if (yych <= ':') goto yy60; - goto yy31; + if (yych <= '9') goto yy81; + if (yych <= ':') goto yy34; + goto yy5; } } } -yy109: - YYDEBUG(109, *YYCURSOR); +yy83: + YYDEBUG(83, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 93 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1205,39 +963,39 @@ yy109: yylval->num = atoi(text); return T_REQ_ID; } -#line 1209 "sapi/phpdbg/phpdbg_lexer.c" -yy110: - YYDEBUG(110, *YYCURSOR); +#line 967 "sapi/phpdbg/phpdbg_lexer.c" +yy84: + YYDEBUG(84, *YYCURSOR); yyaccept = 4; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(111, *YYCURSOR); + YYDEBUG(85, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy110; + goto yy84; } if (yych <= ' ') { if (yych <= '\n') { - if (yych <= 0x00) goto yy112; - if (yych <= 0x08) goto yy31; + if (yych <= 0x00) goto yy86; + if (yych <= 0x08) goto yy5; } else { - if (yych == '\r') goto yy112; - if (yych <= 0x1F) goto yy31; + if (yych == '\r') goto yy86; + if (yych <= 0x1F) goto yy5; } } else { if (yych <= '&') { - if (yych <= '!') goto yy31; - if (yych <= '"') goto yy58; - if (yych >= '$') goto yy31; + if (yych <= '!') goto yy5; + if (yych <= '"') goto yy32; + if (yych >= '$') goto yy5; } else { - if (yych <= '\'') goto yy58; - if (yych <= '/') goto yy31; - if (yych <= ':') goto yy60; - goto yy31; + if (yych <= '\'') goto yy32; + if (yych <= '/') goto yy5; + if (yych <= ':') goto yy34; + goto yy5; } } -yy112: - YYDEBUG(112, *YYCURSOR); +yy86: + YYDEBUG(86, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 148 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1245,48 +1003,48 @@ yy112: yylval->addr = strtoul(yytext, 0, 16); return T_ADDR; } -#line 1249 "sapi/phpdbg/phpdbg_lexer.c" -yy113: - YYDEBUG(113, *YYCURSOR); +#line 1007 "sapi/phpdbg/phpdbg_lexer.c" +yy87: + YYDEBUG(87, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - if (yych == '\\') goto yy83; - goto yy38; -yy114: - YYDEBUG(114, *YYCURSOR); + if (yych == '\\') goto yy57; + goto yy12; +yy88: + YYDEBUG(88, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy134; - if (yych == 'a') goto yy134; - goto yy32; -yy115: - YYDEBUG(115, *YYCURSOR); + if (yych == 'A') goto yy108; + if (yych == 'a') goto yy108; + goto yy6; +yy89: + YYDEBUG(89, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy135; - if (yych == 'b') goto yy135; - goto yy32; -yy116: - YYDEBUG(116, *YYCURSOR); + if (yych == 'B') goto yy109; + if (yych == 'b') goto yy109; + goto yy6; +yy90: + YYDEBUG(90, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy136; - if (yych == 's') goto yy136; - goto yy32; -yy117: - YYDEBUG(117, *YYCURSOR); + if (yych == 'S') goto yy110; + if (yych == 's') goto yy110; + goto yy6; +yy91: + YYDEBUG(91, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(118, *YYCURSOR); + YYDEBUG(92, *YYCURSOR); if (yych <= '\f') { - if (yych == '\t') goto yy117; + if (yych == '\t') goto yy91; } else { - if (yych <= '\r') goto yy117; - if (yych == ' ') goto yy117; + if (yych <= '\r') goto yy91; + if (yych == ' ') goto yy91; } - YYDEBUG(119, *YYCURSOR); + YYDEBUG(93, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 100 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1294,12 +1052,12 @@ yy117: phpdbg_init_param(yylval, EMPTY_PARAM); return T_IF; } -#line 1298 "sapi/phpdbg/phpdbg_lexer.c" -yy120: - YYDEBUG(120, *YYCURSOR); +#line 1056 "sapi/phpdbg/phpdbg_lexer.c" +yy94: + YYDEBUG(94, *YYCURSOR); ++YYCURSOR; - YYDEBUG(121, *YYCURSOR); - YYCURSOR = YYCTXMARKER; + YYDEBUG(95, *YYCURSOR); + YYCURSOR -= 1; yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 136 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1307,12 +1065,12 @@ yy120: yylval->num = 0; return T_FALSY; } -#line 1311 "sapi/phpdbg/phpdbg_lexer.c" -yy122: - YYDEBUG(122, *YYCURSOR); +#line 1069 "sapi/phpdbg/phpdbg_lexer.c" +yy96: + YYDEBUG(96, *YYCURSOR); ++YYCURSOR; - YYDEBUG(123, *YYCURSOR); - YYCURSOR = YYCTXMARKER; + YYDEBUG(97, *YYCURSOR); + YYCURSOR -= 1; yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 130 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1320,31 +1078,31 @@ yy122: yylval->num = 1; return T_TRUTHY; } -#line 1324 "sapi/phpdbg/phpdbg_lexer.c" -yy124: - YYDEBUG(124, *YYCURSOR); +#line 1082 "sapi/phpdbg/phpdbg_lexer.c" +yy98: + YYDEBUG(98, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy91; - if (yych == 'e') goto yy91; - goto yy32; -yy125: - YYDEBUG(125, *YYCURSOR); + if (yych == 'E') goto yy65; + if (yych == 'e') goto yy65; + goto yy6; +yy99: + YYDEBUG(99, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy137; - goto yy32; -yy126: - YYDEBUG(126, *YYCURSOR); + if (yych == 'D') goto yy111; + goto yy6; +yy100: + YYDEBUG(100, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'd') goto yy137; - goto yy32; -yy127: - YYDEBUG(127, *YYCURSOR); + if (yych == 'd') goto yy111; + goto yy6; +yy101: + YYDEBUG(101, *YYCURSOR); ++YYCURSOR; -yy128: - YYDEBUG(128, *YYCURSOR); +yy102: + YYDEBUG(102, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 123 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1353,131 +1111,131 @@ yy128: yylval->len = yyleng; return T_PROTO; } -#line 1357 "sapi/phpdbg/phpdbg_lexer.c" -yy129: - YYDEBUG(129, *YYCURSOR); +#line 1115 "sapi/phpdbg/phpdbg_lexer.c" +yy103: + YYDEBUG(103, *YYCURSOR); yyaccept = 5; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x00) goto yy128; - if (yych == '\n') goto yy128; - goto yy64; -yy130: - YYDEBUG(130, *YYCURSOR); + if (yych <= 0x00) goto yy102; + if (yych == '\n') goto yy102; + goto yy38; +yy104: + YYDEBUG(104, *YYCURSOR); yyaccept = 5; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x00) goto yy128; - if (yych == '\n') goto yy128; - goto yy74; -yy131: - YYDEBUG(131, *YYCURSOR); + if (yych <= 0x00) goto yy102; + if (yych == '\n') goto yy102; + goto yy48; +yy105: + YYDEBUG(105, *YYCURSOR); yych = *++YYCURSOR; - if (yych == '.') goto yy132; - if (yych <= '/') goto yy38; - if (yych >= ':') goto yy38; -yy132: - YYDEBUG(132, *YYCURSOR); + if (yych == '.') goto yy106; + if (yych <= '/') goto yy12; + if (yych >= ':') goto yy12; +yy106: + YYDEBUG(106, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(133, *YYCURSOR); - if (yych == '.') goto yy132; - if (yych <= '/') goto yy109; - if (yych <= '9') goto yy132; - goto yy109; -yy134: - YYDEBUG(134, *YYCURSOR); + YYDEBUG(107, *YYCURSOR); + if (yych == '.') goto yy106; + if (yych <= '/') goto yy83; + if (yych <= '9') goto yy106; + goto yy83; +yy108: + YYDEBUG(108, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy138; - if (yych == 'b') goto yy138; - goto yy32; -yy135: - YYDEBUG(135, *YYCURSOR); + if (yych == 'B') goto yy112; + if (yych == 'b') goto yy112; + goto yy6; +yy109: + YYDEBUG(109, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy139; - if (yych == 'l') goto yy139; - goto yy32; -yy136: - YYDEBUG(136, *YYCURSOR); + if (yych == 'L') goto yy113; + if (yych == 'l') goto yy113; + goto yy6; +yy110: + YYDEBUG(110, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy89; - if (yych == 'e') goto yy89; - goto yy32; -yy137: - YYDEBUG(137, *YYCURSOR); + if (yych == 'E') goto yy63; + if (yych == 'e') goto yy63; + goto yy6; +yy111: + YYDEBUG(111, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == '_') goto yy140; - goto yy32; -yy138: - YYDEBUG(138, *YYCURSOR); + if (yych == '_') goto yy114; + goto yy6; +yy112: + YYDEBUG(112, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy141; - if (yych == 'l') goto yy141; - goto yy32; -yy139: - YYDEBUG(139, *YYCURSOR); + if (yych == 'L') goto yy115; + if (yych == 'l') goto yy115; + goto yy6; +yy113: + YYDEBUG(113, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy142; - if (yych == 'e') goto yy142; - goto yy32; -yy140: - YYDEBUG(140, *YYCURSOR); + if (yych == 'E') goto yy116; + if (yych == 'e') goto yy116; + goto yy6; +yy114: + YYDEBUG(114, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 128) { - goto yy143; + goto yy117; } - goto yy32; -yy141: - YYDEBUG(141, *YYCURSOR); + goto yy6; +yy115: + YYDEBUG(115, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy146; - if (yych == 'e') goto yy146; - goto yy32; -yy142: - YYDEBUG(142, *YYCURSOR); + if (yych == 'E') goto yy120; + if (yych == 'e') goto yy120; + goto yy6; +yy116: + YYDEBUG(116, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy91; - if (yych == 'd') goto yy91; - goto yy32; -yy143: - YYDEBUG(143, *YYCURSOR); + if (yych == 'D') goto yy65; + if (yych == 'd') goto yy65; + goto yy6; +yy117: + YYDEBUG(117, *YYCURSOR); yyaccept = 6; YYMARKER = ++YYCURSOR; YYFILL(3); yych = *YYCURSOR; - YYDEBUG(144, *YYCURSOR); + YYDEBUG(118, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy143; + goto yy117; } if (yych <= ' ') { if (yych <= '\n') { - if (yych <= 0x00) goto yy145; - if (yych <= 0x08) goto yy31; + if (yych <= 0x00) goto yy119; + if (yych <= 0x08) goto yy5; } else { - if (yych == '\r') goto yy145; - if (yych <= 0x1F) goto yy31; + if (yych == '\r') goto yy119; + if (yych <= 0x1F) goto yy5; } } else { if (yych <= '&') { - if (yych <= '!') goto yy31; - if (yych <= '"') goto yy58; - if (yych >= '$') goto yy31; + if (yych <= '!') goto yy5; + if (yych <= '"') goto yy32; + if (yych >= '$') goto yy5; } else { - if (yych <= '\'') goto yy58; - if (yych == ':') goto yy60; - goto yy31; + if (yych <= '\'') goto yy32; + if (yych == ':') goto yy34; + goto yy5; } } -yy145: - YYDEBUG(145, *YYCURSOR); +yy119: + YYDEBUG(119, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 154 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1486,14 +1244,14 @@ yy145: yylval->len = yyleng; return T_OPCODE; } -#line 1490 "sapi/phpdbg/phpdbg_lexer.c" -yy146: - YYDEBUG(146, *YYCURSOR); +#line 1248 "sapi/phpdbg/phpdbg_lexer.c" +yy120: + YYDEBUG(120, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy89; - if (yych == 'd') goto yy89; - goto yy32; + if (yych == 'D') goto yy63; + if (yych == 'd') goto yy63; + goto yy6; } /* *********************************** */ yyc_PRE_RAW: @@ -1532,23 +1290,23 @@ yyc_PRE_RAW: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - YYDEBUG(147, *YYCURSOR); + YYDEBUG(121, *YYCURSOR); YYFILL(2); yych = *YYCURSOR; if (yych <= '\r') { - if (yych == '\t') goto yy151; - if (yych >= '\r') goto yy151; + if (yych == '\t') goto yy125; + if (yych >= '\r') goto yy125; } else { if (yych <= ' ') { - if (yych >= ' ') goto yy152; + if (yych >= ' ') goto yy126; } else { - if (yych == '-') goto yy155; + if (yych == '-') goto yy129; } } - YYDEBUG(149, *YYCURSOR); + YYDEBUG(123, *YYCURSOR); ++YYCURSOR; -yy150: - YYDEBUG(150, *YYCURSOR); +yy124: + YYDEBUG(124, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 199 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1557,24 +1315,24 @@ yy150: YYCURSOR = LEX(text); goto restart; } -#line 1561 "sapi/phpdbg/phpdbg_lexer.c" -yy151: - YYDEBUG(151, *YYCURSOR); +#line 1319 "sapi/phpdbg/phpdbg_lexer.c" +yy125: + YYDEBUG(125, *YYCURSOR); yych = *++YYCURSOR; if (yybm[0+yych] & 64) { - goto yy152; + goto yy126; } - goto yy150; -yy152: - YYDEBUG(152, *YYCURSOR); + goto yy124; +yy126: + YYDEBUG(126, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(153, *YYCURSOR); + YYDEBUG(127, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy152; + goto yy126; } - YYDEBUG(154, *YYCURSOR); + YYDEBUG(128, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 175 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1582,51 +1340,51 @@ yy152: goto restart; } -#line 1586 "sapi/phpdbg/phpdbg_lexer.c" -yy155: - YYDEBUG(155, *YYCURSOR); +#line 1344 "sapi/phpdbg/phpdbg_lexer.c" +yy129: + YYDEBUG(129, *YYCURSOR); yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'r') goto yy150; -yy156: - YYDEBUG(156, *YYCURSOR); + if (yych != 'r') goto yy124; +yy130: + YYDEBUG(130, *YYCURSOR); ++YYCURSOR; YYFILL(2); yych = *YYCURSOR; - YYDEBUG(157, *YYCURSOR); + YYDEBUG(131, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy160; + goto yy134; } if (yych <= '\r') { - if (yych == '\t') goto yy156; - if (yych >= '\r') goto yy156; + if (yych == '\t') goto yy130; + if (yych >= '\r') goto yy130; } else { if (yych <= ' ') { - if (yych >= ' ') goto yy156; + if (yych >= ' ') goto yy130; } else { - if (yych == '-') goto yy159; + if (yych == '-') goto yy133; } } -yy158: - YYDEBUG(158, *YYCURSOR); +yy132: + YYDEBUG(132, *YYCURSOR); YYCURSOR = YYMARKER; - goto yy150; -yy159: - YYDEBUG(159, *YYCURSOR); + goto yy124; +yy133: + YYDEBUG(133, *YYCURSOR); yych = *++YYCURSOR; if (yybm[0+yych] & 128) { - goto yy160; + goto yy134; } - goto yy158; -yy160: - YYDEBUG(160, *YYCURSOR); + goto yy132; +yy134: + YYDEBUG(134, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(161, *YYCURSOR); + YYDEBUG(135, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy160; + goto yy134; } - YYDEBUG(162, *YYCURSOR); + YYDEBUG(136, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 93 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1635,7 +1393,7 @@ yy160: yylval->num = atoi(text); return T_REQ_ID; } -#line 1639 "sapi/phpdbg/phpdbg_lexer.c" +#line 1397 "sapi/phpdbg/phpdbg_lexer.c" } /* *********************************** */ yyc_RAW: @@ -1674,43 +1432,43 @@ yyc_RAW: 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, }; - YYDEBUG(163, *YYCURSOR); + YYDEBUG(137, *YYCURSOR); YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 8) { - goto yy167; + goto yy141; } - if (yych <= '\n') goto yy165; - if (yych <= '"') goto yy170; - if (yych <= '#') goto yy172; - if (yych <= '\'') goto yy174; - goto yy175; -yy165: - YYDEBUG(165, *YYCURSOR); + if (yych <= '\n') goto yy139; + if (yych <= '"') goto yy144; + if (yych <= '#') goto yy146; + if (yych <= '\'') goto yy148; + goto yy149; +yy139: + YYDEBUG(139, *YYCURSOR); ++YYCURSOR; - YYDEBUG(166, *YYCURSOR); + YYDEBUG(140, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 89 "sapi/phpdbg/phpdbg_lexer.l" { return 0; } -#line 1698 "sapi/phpdbg/phpdbg_lexer.c" -yy167: - YYDEBUG(167, *YYCURSOR); +#line 1456 "sapi/phpdbg/phpdbg_lexer.c" +yy141: + YYDEBUG(141, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(168, *YYCURSOR); + YYDEBUG(142, *YYCURSOR); if (yybm[0+yych] & 8) { - goto yy167; + goto yy141; } - if (yych <= '\n') goto yy169; - if (yych <= '"') goto yy170; - if (yych <= '#') goto yy169; - if (yych <= '\'') goto yy174; - goto yy175; -yy169: - YYDEBUG(169, *YYCURSOR); + if (yych <= '\n') goto yy143; + if (yych <= '"') goto yy144; + if (yych <= '#') goto yy143; + if (yych <= '\'') goto yy148; + goto yy149; +yy143: + YYDEBUG(143, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 168 "sapi/phpdbg/phpdbg_lexer.l" { @@ -1719,363 +1477,608 @@ yy169: yylval->len = yyleng; return T_INPUT; } -#line 1723 "sapi/phpdbg/phpdbg_lexer.c" -yy170: - YYDEBUG(170, *YYCURSOR); +#line 1481 "sapi/phpdbg/phpdbg_lexer.c" +yy144: + YYDEBUG(144, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 32) { - goto yy177; + goto yy151; } - if (yych >= '#') goto yy179; -yy171: - YYDEBUG(171, *YYCURSOR); + if (yych >= '#') goto yy153; +yy145: + YYDEBUG(145, *YYCURSOR); YYCURSOR = YYMARKER; - goto yy169; -yy172: - YYDEBUG(172, *YYCURSOR); + goto yy143; +yy146: + YYDEBUG(146, *YYCURSOR); ++YYCURSOR; - YYDEBUG(173, *YYCURSOR); + YYDEBUG(147, *YYCURSOR); yyleng = (size_t) YYCURSOR - (size_t) yytext; #line 110 "sapi/phpdbg/phpdbg_lexer.l" { YYSETCONDITION(INITIAL); return T_SEPARATOR; } -#line 1747 "sapi/phpdbg/phpdbg_lexer.c" -yy174: - YYDEBUG(174, *YYCURSOR); +#line 1505 "sapi/phpdbg/phpdbg_lexer.c" +yy148: + YYDEBUG(148, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 64) { - goto yy181; + goto yy155; } - if (yych <= '\'') goto yy171; - goto yy183; -yy175: - YYDEBUG(175, *YYCURSOR); + if (yych <= '\'') goto yy145; + goto yy157; +yy149: + YYDEBUG(149, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(176, *YYCURSOR); + YYDEBUG(150, *YYCURSOR); if (yybm[0+yych] & 16) { - goto yy175; + goto yy149; } if (yych <= '!') { - if (yych <= 0x00) goto yy169; - if (yych == '\n') goto yy169; - goto yy167; + if (yych <= 0x00) goto yy143; + if (yych == '\n') goto yy143; + goto yy141; } else { - if (yych <= '"') goto yy185; - if (yych == '\'') goto yy186; - goto yy167; + if (yych <= '"') goto yy159; + if (yych == '\'') goto yy160; + goto yy141; } -yy177: - YYDEBUG(177, *YYCURSOR); +yy151: + YYDEBUG(151, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(178, *YYCURSOR); + YYDEBUG(152, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy177; + goto yy151; } - if (yych <= '\n') goto yy171; - if (yych <= '"') goto yy167; -yy179: - YYDEBUG(179, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '"') goto yy141; +yy153: + YYDEBUG(153, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(180, *YYCURSOR); + YYDEBUG(154, *YYCURSOR); if (yybm[0+yych] & 32) { - goto yy177; + goto yy151; } - if (yych <= '\n') goto yy171; - if (yych <= '"') goto yy187; - goto yy179; -yy181: - YYDEBUG(181, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '"') goto yy161; + goto yy153; +yy155: + YYDEBUG(155, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(182, *YYCURSOR); + YYDEBUG(156, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy181; + goto yy155; } - if (yych <= '\n') goto yy171; - if (yych <= '\'') goto yy167; -yy183: - YYDEBUG(183, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '\'') goto yy141; +yy157: + YYDEBUG(157, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(184, *YYCURSOR); + YYDEBUG(158, *YYCURSOR); if (yybm[0+yych] & 64) { - goto yy181; + goto yy155; } - if (yych <= '\n') goto yy171; - if (yych <= '\'') goto yy189; - goto yy183; -yy185: - YYDEBUG(185, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '\'') goto yy163; + goto yy157; +yy159: + YYDEBUG(159, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; - goto yy187; + if (yych <= 0x00) goto yy143; + goto yy161; } else { - if (yych <= '\n') goto yy169; - if (yych <= '!') goto yy187; - goto yy170; + if (yych <= '\n') goto yy143; + if (yych <= '!') goto yy161; + goto yy144; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy177; - if (yych <= '&') goto yy187; - goto yy191; + if (yych <= '#') goto yy151; + if (yych <= '&') goto yy161; + goto yy165; } else { - if (yych == '\\') goto yy192; - goto yy187; + if (yych == '\\') goto yy166; + goto yy161; } } -yy186: - YYDEBUG(186, *YYCURSOR); +yy160: + YYDEBUG(160, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; - goto yy189; + if (yych <= 0x00) goto yy143; + goto yy163; } else { - if (yych <= '\n') goto yy169; - if (yych <= '!') goto yy189; - goto yy194; + if (yych <= '\n') goto yy143; + if (yych <= '!') goto yy163; + goto yy168; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy181; - if (yych <= '&') goto yy189; - goto yy174; + if (yych <= '#') goto yy155; + if (yych <= '&') goto yy163; + goto yy148; } else { - if (yych == '\\') goto yy195; - goto yy189; + if (yych == '\\') goto yy169; + goto yy163; } } -yy187: - YYDEBUG(187, *YYCURSOR); +yy161: + YYDEBUG(161, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(188, *YYCURSOR); + YYDEBUG(162, *YYCURSOR); if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; - goto yy187; + if (yych <= 0x00) goto yy143; + goto yy161; } else { - if (yych <= '\n') goto yy169; - if (yych <= '!') goto yy187; - goto yy185; + if (yych <= '\n') goto yy143; + if (yych <= '!') goto yy161; + goto yy159; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy177; - if (yych <= '&') goto yy187; - goto yy191; + if (yych <= '#') goto yy151; + if (yych <= '&') goto yy161; + goto yy165; } else { - if (yych == '\\') goto yy192; - goto yy187; + if (yych == '\\') goto yy166; + goto yy161; } } -yy189: - YYDEBUG(189, *YYCURSOR); +yy163: + YYDEBUG(163, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(190, *YYCURSOR); + YYDEBUG(164, *YYCURSOR); if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; - goto yy189; + if (yych <= 0x00) goto yy143; + goto yy163; } else { - if (yych <= '\n') goto yy169; - if (yych <= '!') goto yy189; - goto yy194; + if (yych <= '\n') goto yy143; + if (yych <= '!') goto yy163; + goto yy168; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy181; - if (yych <= '&') goto yy189; - goto yy186; + if (yych <= '#') goto yy155; + if (yych <= '&') goto yy163; + goto yy160; } else { - if (yych == '\\') goto yy195; - goto yy189; + if (yych == '\\') goto yy169; + goto yy163; } } -yy191: - YYDEBUG(191, *YYCURSOR); +yy165: + YYDEBUG(165, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 128) { - goto yy197; + goto yy171; } - if (yych <= '\n') goto yy171; - if (yych <= '"') goto yy189; - if (yych <= '\'') goto yy177; - goto yy199; -yy192: - YYDEBUG(192, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '"') goto yy163; + if (yych <= '\'') goto yy151; + goto yy173; +yy166: + YYDEBUG(166, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(193, *YYCURSOR); + YYDEBUG(167, *YYCURSOR); if (yych <= '&') { - if (yych <= 0x00) goto yy169; - if (yych == '\n') goto yy169; - goto yy187; + if (yych <= 0x00) goto yy143; + if (yych == '\n') goto yy143; + goto yy161; } else { - if (yych <= '\'') goto yy201; - if (yych == '\\') goto yy192; - goto yy187; + if (yych <= '\'') goto yy175; + if (yych == '\\') goto yy166; + goto yy161; } -yy194: - YYDEBUG(194, *YYCURSOR); +yy168: + YYDEBUG(168, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yybm[0+yych] & 128) { - goto yy197; + goto yy171; } - if (yych <= '\n') goto yy171; - if (yych <= '"') goto yy181; - if (yych <= '\'') goto yy187; - goto yy199; -yy195: - YYDEBUG(195, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '"') goto yy155; + if (yych <= '\'') goto yy161; + goto yy173; +yy169: + YYDEBUG(169, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(196, *YYCURSOR); + YYDEBUG(170, *YYCURSOR); if (yych <= '!') { - if (yych <= 0x00) goto yy169; - if (yych == '\n') goto yy169; - goto yy189; + if (yych <= 0x00) goto yy143; + if (yych == '\n') goto yy143; + goto yy163; } else { - if (yych <= '"') goto yy202; - if (yych == '\\') goto yy195; - goto yy189; + if (yych <= '"') goto yy176; + if (yych == '\\') goto yy169; + goto yy163; } -yy197: - YYDEBUG(197, *YYCURSOR); +yy171: + YYDEBUG(171, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(198, *YYCURSOR); + YYDEBUG(172, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy197; + goto yy171; } - if (yych <= '\n') goto yy171; - if (yych <= '"') goto yy189; - if (yych <= '\'') goto yy187; -yy199: - YYDEBUG(199, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '"') goto yy163; + if (yych <= '\'') goto yy161; +yy173: + YYDEBUG(173, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(200, *YYCURSOR); + YYDEBUG(174, *YYCURSOR); if (yybm[0+yych] & 128) { - goto yy197; + goto yy171; } - if (yych <= '\n') goto yy171; - if (yych <= '\'') goto yy203; - goto yy199; -yy201: - YYDEBUG(201, *YYCURSOR); + if (yych <= '\n') goto yy145; + if (yych <= '\'') goto yy177; + goto yy173; +yy175: + YYDEBUG(175, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; - goto yy203; + if (yych <= 0x00) goto yy143; + goto yy177; } else { - if (yych <= '\n') goto yy169; - if (yych <= '!') goto yy203; + if (yych <= '\n') goto yy143; + if (yych <= '!') goto yy177; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy197; - if (yych <= '&') goto yy203; - goto yy191; + if (yych <= '#') goto yy171; + if (yych <= '&') goto yy177; + goto yy165; } else { - if (yych == '\\') goto yy205; - goto yy203; + if (yych == '\\') goto yy179; + goto yy177; } } -yy202: - YYDEBUG(202, *YYCURSOR); +yy176: + YYDEBUG(176, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; + if (yych <= 0x00) goto yy143; } else { - if (yych <= '\n') goto yy169; - if (yych >= '"') goto yy194; + if (yych <= '\n') goto yy143; + if (yych >= '"') goto yy168; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy197; - if (yych >= '\'') goto yy201; + if (yych <= '#') goto yy171; + if (yych >= '\'') goto yy175; } else { - if (yych == '\\') goto yy205; + if (yych == '\\') goto yy179; } } -yy203: - YYDEBUG(203, *YYCURSOR); +yy177: + YYDEBUG(177, *YYCURSOR); YYMARKER = ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(204, *YYCURSOR); + YYDEBUG(178, *YYCURSOR); if (yych <= '"') { if (yych <= '\t') { - if (yych <= 0x00) goto yy169; - goto yy203; + if (yych <= 0x00) goto yy143; + goto yy177; } else { - if (yych <= '\n') goto yy169; - if (yych <= '!') goto yy203; - goto yy202; + if (yych <= '\n') goto yy143; + if (yych <= '!') goto yy177; + goto yy176; } } else { if (yych <= '\'') { - if (yych <= '#') goto yy197; - if (yych <= '&') goto yy203; - goto yy201; + if (yych <= '#') goto yy171; + if (yych <= '&') goto yy177; + goto yy175; } else { - if (yych != '\\') goto yy203; + if (yych != '\\') goto yy177; } } -yy205: - YYDEBUG(205, *YYCURSOR); +yy179: + YYDEBUG(179, *YYCURSOR); ++YYCURSOR; YYFILL(1); yych = *YYCURSOR; - YYDEBUG(206, *YYCURSOR); + YYDEBUG(180, *YYCURSOR); if (yych <= '\n') { - if (yych <= 0x00) goto yy169; - if (yych <= '\t') goto yy203; - goto yy169; + if (yych <= 0x00) goto yy143; + if (yych <= '\t') goto yy177; + goto yy143; } else { - if (yych == '\\') goto yy205; - goto yy203; + if (yych == '\\') goto yy179; + goto yy177; } } +/* *********************************** */ +yyc_INITIAL: + { + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 0, 128, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + YYDEBUG(181, *YYCURSOR); + YYFILL(4); + yych = *YYCURSOR; + if (yych <= 'E') { + if (yych <= '\r') { + if (yych == '\t') goto yy185; + if (yych >= '\r') goto yy185; + } else { + if (yych == ' ') goto yy186; + if (yych >= 'E') goto yy189; + } + } else { + if (yych <= 'd') { + if (yych <= 'Q') goto yy183; + if (yych <= 'R') goto yy190; + if (yych <= 'S') goto yy191; + } else { + if (yych <= 'q') { + if (yych <= 'e') goto yy189; + } else { + if (yych <= 'r') goto yy192; + if (yych <= 's') goto yy191; + } + } + } +yy183: + YYDEBUG(183, *YYCURSOR); + ++YYCURSOR; +yy184: + YYDEBUG(184, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 206 "sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(NORMAL); + + YYCURSOR = LEX(text); + goto restart; +} +#line 1913 "sapi/phpdbg/phpdbg_lexer.c" +yy185: + YYDEBUG(185, *YYCURSOR); + yych = *++YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy186; + } + goto yy184; +yy186: + YYDEBUG(186, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(187, *YYCURSOR); + if (yybm[0+yych] & 128) { + goto yy186; + } + YYDEBUG(188, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 175 "sapi/phpdbg/phpdbg_lexer.l" + { + /* ignore whitespace */ + + goto restart; +} +#line 1938 "sapi/phpdbg/phpdbg_lexer.c" +yy189: + YYDEBUG(189, *YYCURSOR); + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'V') goto yy193; + if (yych == 'v') goto yy193; + goto yy184; +yy190: + YYDEBUG(190, *YYCURSOR); + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'U') goto yy195; + if (yych == 'u') goto yy195; + goto yy184; +yy191: + YYDEBUG(191, *YYCURSOR); + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'H') goto yy196; + if (yych == 'h') goto yy196; + goto yy184; +yy192: + YYDEBUG(192, *YYCURSOR); + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 0x1F) { + if (yych <= '\t') { + if (yych <= 0x08) goto yy184; + goto yy197; + } else { + if (yych == '\r') goto yy197; + goto yy184; + } + } else { + if (yych <= 'U') { + if (yych <= ' ') goto yy197; + if (yych <= 'T') goto yy184; + goto yy195; + } else { + if (yych == 'u') goto yy195; + goto yy184; + } + } +yy193: + YYDEBUG(193, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych == '\t') goto yy200; + } else { + if (yych <= '\r') goto yy200; + if (yych == ' ') goto yy200; + } +yy194: + YYDEBUG(194, *YYCURSOR); + YYCURSOR = YYMARKER; + goto yy184; +yy195: + YYDEBUG(195, *YYCURSOR); + yych = *++YYCURSOR; + if (yych == 'N') goto yy203; + if (yych == 'n') goto yy203; + goto yy194; +yy196: + YYDEBUG(196, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych == '\t') goto yy204; + goto yy194; + } else { + if (yych <= '\r') goto yy204; + if (yych == ' ') goto yy204; + goto yy194; + } +yy197: + YYDEBUG(197, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(198, *YYCURSOR); + if (yych <= '\f') { + if (yych == '\t') goto yy197; + } else { + if (yych <= '\r') goto yy197; + if (yych == ' ') goto yy197; + } + YYDEBUG(199, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 193 "sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(PRE_RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_RUN; +} +#line 2028 "sapi/phpdbg/phpdbg_lexer.c" +yy200: + YYDEBUG(200, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(201, *YYCURSOR); + if (yych <= '\f') { + if (yych == '\t') goto yy200; + } else { + if (yych <= '\r') goto yy200; + if (yych == ' ') goto yy200; + } + YYDEBUG(202, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 181 "sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(PRE_RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_EVAL; +} +#line 2049 "sapi/phpdbg/phpdbg_lexer.c" +yy203: + YYDEBUG(203, *YYCURSOR); + yych = *++YYCURSOR; + if (yych <= '\f') { + if (yych == '\t') goto yy197; + goto yy194; + } else { + if (yych <= '\r') goto yy197; + if (yych == ' ') goto yy197; + goto yy194; + } +yy204: + YYDEBUG(204, *YYCURSOR); + ++YYCURSOR; + YYFILL(1); + yych = *YYCURSOR; + YYDEBUG(205, *YYCURSOR); + if (yych <= '\f') { + if (yych == '\t') goto yy204; + } else { + if (yych <= '\r') goto yy204; + if (yych == ' ') goto yy204; + } + YYDEBUG(206, *YYCURSOR); + yyleng = (size_t) YYCURSOR - (size_t) yytext; +#line 187 "sapi/phpdbg/phpdbg_lexer.l" + { + YYSETCONDITION(PRE_RAW); + phpdbg_init_param(yylval, EMPTY_PARAM); + return T_SHELL; +} +#line 2081 "sapi/phpdbg/phpdbg_lexer.c" + } } #line 213 "sapi/phpdbg/phpdbg_lexer.l" diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index 0fd3d17edf..b14a1c23e2 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -37,7 +37,7 @@ static inline const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ } /* }}} */ static inline char *phpdbg_decode_op( - zend_op_array *ops, const znode_op *op, uint32_t type) /* {{{ */ + zend_op_array *ops, const zend_op *opline, const znode_op *op, uint32_t type) /* {{{ */ { char *decode = NULL; @@ -56,7 +56,7 @@ static inline char *phpdbg_decode_op( spprintf(&decode, 0, "~%u", EX_VAR_TO_NUM(op->var) - ops->last_var); break; case IS_CONST: { - zval *literal = RT_CONSTANT(ops, *op); + zval *literal = RT_CONSTANT(opline, *op); decode = phpdbg_short_zval_print(literal, 20); } break; } @@ -68,7 +68,7 @@ char *phpdbg_decode_input_op( uint32_t flags) { char *result = NULL; if (op_type != IS_UNUSED) { - result = phpdbg_decode_op(ops, &op, op_type); + result = phpdbg_decode_op(ops, opline, &op, op_type); } else if (ZEND_VM_OP_JMP_ADDR == (flags & ZEND_VM_OP_MASK)) { spprintf(&result, 0, "J%td", OP_JMP_ADDR(opline, op) - ops->opcodes); } else if (ZEND_VM_OP_NUM == (flags & ZEND_VM_OP_MASK)) { @@ -77,10 +77,6 @@ char *phpdbg_decode_input_op( if (op.num != (uint32_t)-1) { spprintf(&result, 0, "try-catch(%" PRIu32 ")", op.num); } - } else if (ZEND_VM_OP_LIVE_RANGE == (flags & ZEND_VM_OP_MASK)) { - if (opline->extended_value & ZEND_FREE_ON_RETURN) { - spprintf(&result, 0, "live-range(%" PRIu32 ")", op.num); - } } else if (ZEND_VM_OP_THIS == (flags & ZEND_VM_OP_MASK)) { result = estrdup("THIS"); } else if (ZEND_VM_OP_NEXT == (flags & ZEND_VM_OP_MASK)) { @@ -115,10 +111,16 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *opline) /*{{{ */ /* RESULT */ switch (opline->opcode) { case ZEND_CATCH: - spprintf(&decode[3], 0, "%" PRIu32, opline->result.num); + if (opline->extended_value & ZEND_LAST_CATCH) { + if (decode[2]) { + efree(decode[2]); + decode[2] = NULL; + } + } + decode[3] = phpdbg_decode_op(ops, opline, &opline->result, opline->result_type); break; default: - decode[3] = phpdbg_decode_op(ops, &opline->result, opline->result_type); + decode[3] = phpdbg_decode_op(ops, opline, &opline->result, opline->result_type); break; } diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c index 1f35a3d1d5..545e1c951d 100644 --- a/sapi/phpdbg/phpdbg_out.c +++ b/sapi/phpdbg/phpdbg_out.c @@ -799,7 +799,7 @@ fmt_error: if (adjust_width && adjust == LEFT && min_width > s_len) PAD(min_width, s_len, pad_char); if (free_zcopy) { - zval_dtor(&zcopy); + zval_ptr_dtor_str(&zcopy); } } skip_output: diff --git a/sapi/phpdbg/phpdbg_out.h b/sapi/phpdbg/phpdbg_out.h index 4d264ba53c..da5cb0c4f8 100644 --- a/sapi/phpdbg/phpdbg_out.h +++ b/sapi/phpdbg/phpdbg_out.h @@ -34,11 +34,18 @@ enum { P_LOG }; -PHPDBG_API int phpdbg_print(int severity, int fd, const char *tag, const char *xmlfmt, const char *strfmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 5, 6); -PHPDBG_API int phpdbg_xml_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); -PHPDBG_API int phpdbg_log_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); -PHPDBG_API int phpdbg_out_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); -PHPDBG_API int phpdbg_rlog_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); +/* phpdbg uses lots of custom format specifiers, so we disable format checks by default. */ +#if defined(PHPDBG_CHECK_FORMAT_STRINGS) +# define PHPDBG_ATTRIBUTE_FORMAT(type, idx, first) PHP_ATTRIBUTE_FORMAT(type, idx, first) +#else +# define PHPDBG_ATTRIBUTE_FORMAT(type, idx, first) +#endif + +PHPDBG_API int phpdbg_print(int severity, int fd, const char *tag, const char *xmlfmt, const char *strfmt, ...) PHPDBG_ATTRIBUTE_FORMAT(printf, 5, 6); +PHPDBG_API int phpdbg_xml_internal(int fd, const char *fmt, ...) PHPDBG_ATTRIBUTE_FORMAT(printf, 2, 3); +PHPDBG_API int phpdbg_log_internal(int fd, const char *fmt, ...) PHPDBG_ATTRIBUTE_FORMAT(printf, 2, 3); +PHPDBG_API int phpdbg_out_internal(int fd, const char *fmt, ...) PHPDBG_ATTRIBUTE_FORMAT(printf, 2, 3); +PHPDBG_API int phpdbg_rlog_internal(int fd, const char *fmt, ...) PHPDBG_ATTRIBUTE_FORMAT(printf, 2, 3); #define phpdbg_error(tag, xmlfmt, strfmt, ...) phpdbg_print(P_ERROR , PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag, xmlfmt, strfmt, ##__VA_ARGS__) #define phpdbg_notice(tag, xmlfmt, strfmt, ...) phpdbg_print(P_NOTICE , PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag, xmlfmt, strfmt, ##__VA_ARGS__) diff --git a/sapi/phpdbg/phpdbg_parser.c b/sapi/phpdbg/phpdbg_parser.c index 16ca21d5d1..ae7533abe4 100644 --- a/sapi/phpdbg/phpdbg_parser.c +++ b/sapi/phpdbg/phpdbg_parser.c @@ -76,8 +76,6 @@ /* * phpdbg_parser.y * (from php-src root) - * flex sapi/phpdbg/dev/phpdbg_lexer.l - * bison sapi/phpdbg/dev/phpdbg_parser.y */ #include "phpdbg.h" diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y index 527c321f4c..b61c9c0a26 100644 --- a/sapi/phpdbg/phpdbg_parser.y +++ b/sapi/phpdbg/phpdbg_parser.y @@ -3,8 +3,6 @@ /* * phpdbg_parser.y * (from php-src root) - * flex sapi/phpdbg/dev/phpdbg_lexer.l - * bison sapi/phpdbg/dev/phpdbg_parser.y */ #include "phpdbg.h" diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index fd668fcfec..db56476905 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -196,7 +196,7 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */ zval_ptr_dtor(&fretval); } - zval_dtor(&fci.function_name); + zval_ptr_dtor_str(&fci.function_name); efree(lc_name); return SUCCESS; @@ -775,7 +775,7 @@ static inline void phpdbg_handle_exception(void) /* {{{ */ EG(exception) = NULL; ZVAL_OBJ(&zv, ex); - zend_call_method_with_0_params(&zv, ex->ce, NULL, "__tostring", &tmp); + zend_call_method_with_0_params(&zv, ex->ce, &ex->ce->__tostring, "__tostring", &tmp); file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("file"), 1, &rv)); line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv)); @@ -1696,7 +1696,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */ backup_opline = EG(current_execute_data)->opline; \ } \ before_ex = EG(opline_before_exception); \ - ++GC_REFCOUNT(exception); \ + GC_ADDREF(exception); \ zend_clear_exception(); \ } \ if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \ diff --git a/sapi/phpdbg/phpdbg_rinit_hook.c b/sapi/phpdbg/phpdbg_rinit_hook.c index 685c5b75a9..d923f7c1d2 100644 --- a/sapi/phpdbg/phpdbg_rinit_hook.c +++ b/sapi/phpdbg/phpdbg_rinit_hook.c @@ -56,9 +56,9 @@ static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ { struct sockaddr_un sock; int s = socket(AF_UNIX, SOCK_STREAM, 0); - int len = strlen(PHPDBG_WG(path)) + sizeof(sock.sun_family); + size_t len = strlen(PHPDBG_WG(path)) + sizeof(sock.sun_family); char buf[(1 << 8) + 1]; - int buflen; + ssize_t buflen; sock.sun_family = AF_UNIX; strcpy(sock.sun_path, PHPDBG_WG(path)); @@ -67,11 +67,15 @@ static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */ } char *msg = NULL; - char msglen[5] = {0}; - phpdbg_webdata_compress(&msg, (int *)msglen); - - send(s, msglen, 4, 0); - send(s, msg, *(int *) msglen, 0); + size_t msglen = 0; + phpdbg_webdata_compress(&msg, &msglen); + + buf[0] = (msglen >> 0) & 0xff; + buf[1] = (msglen >> 8) & 0xff; + buf[2] = (msglen >> 16) & 0xff; + buf[3] = (msglen >> 24) & 0xff; + send(s, buf, 4, 0); + send(s, msg, msglen, 0); while ((buflen = recv(s, buf, sizeof(buf) - 1, 0)) > 0) { php_write(buf, buflen); diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 380e9f9e16..e10eb60d4a 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -687,10 +687,12 @@ PHPDBG_API void phpdbg_xml_var_dump(zval *zv) { break; case IS_ARRAY: myht = Z_ARRVAL_P(zv); - if (ZEND_HASH_APPLY_PROTECTION(myht) && ++myht->u.v.nApplyCount > 1) { - phpdbg_xml("<recursion />"); - --myht->u.v.nApplyCount; - break; + if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) { + if (GC_IS_RECURSIVE(myht)) { + phpdbg_xml("<recursion />"); + break; + } + GC_PROTECT_RECURSION(myht); } phpdbg_xml("<array refstatus=\"%s\" num=\"%d\">", COMMON, zend_hash_num_elements(myht)); element_dump_func = phpdbg_xml_array_element_dump; @@ -698,9 +700,8 @@ PHPDBG_API void phpdbg_xml_var_dump(zval *zv) { goto head_done; case IS_OBJECT: myht = Z_OBJDEBUG_P(zv, is_temp); - if (myht && ++myht->u.v.nApplyCount > 1) { + if (myht && GC_IS_RECURSIVE(myht)) { phpdbg_xml("<recursion />"); - --myht->u.v.nApplyCount; break; } @@ -715,7 +716,7 @@ head_done: element_dump_func(val, key, num); } ZEND_HASH_FOREACH_END(); zend_hash_apply_with_arguments(myht, (apply_func_args_t) element_dump_func, 0); - --myht->u.v.nApplyCount; + GC_UNPROTECT_RECURSION(myht); if (is_temp) { zend_hash_destroy(myht); efree(myht); @@ -759,21 +760,25 @@ PHPDBG_API zend_bool phpdbg_check_caught_ex(zend_execute_data *execute_data, zen return 1; } - do { + cur = &op_array->opcodes[catch]; + while (1) { zend_class_entry *ce; - cur = &op_array->opcodes[catch]; - if (!(ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(cur->op1))))) { - ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(cur->op1)), EX_CONSTANT(cur->op1) + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD); - CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(cur->op1)), ce); + if (!(ce = CACHED_PTR(cur->extended_value & ~ZEND_LAST_CATCH))) { + ce = zend_fetch_class_by_name(Z_STR_P(RT_CONSTANT(cur, cur->op1)), RT_CONSTANT(cur, cur->op1) + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD); + CACHE_PTR(cur->extended_value & ~ZEND_LAST_CATCH, ce); } if (ce == exception->ce || (ce && instanceof_function(exception->ce, ce))) { return 1; } - catch += cur->extended_value / sizeof(zend_op); - } while (!cur->result.num); + if (cur->extended_value & ZEND_LAST_CATCH) { + return 0; + } + + cur = OP_JMP_ADDR(cur, cur->op2); + } return 0; } @@ -819,7 +824,7 @@ char *phpdbg_short_zval_print(zval *zv, int maxlen) /* {{{ */ break; case IS_STRING: { int i; - zend_string *str = php_addcslashes(Z_STR_P(zv), 0, "\\\"\n\t\0", 5); + zend_string *str = php_addcslashes(Z_STR_P(zv), "\\\"\n\t\0", 5); for (i = 0; i < ZSTR_LEN(str); i++) { if (ZSTR_VAL(str)[i] < 32) { ZSTR_VAL(str)[i] = ' '; @@ -843,12 +848,17 @@ char *phpdbg_short_zval_print(zval *zv, int maxlen) /* {{{ */ ZSTR_VAL(str), ZSTR_LEN(str) <= maxlen ? 0 : '+'); break; } - case IS_CONSTANT: - decode = estrdup("<constant>"); - break; - case IS_CONSTANT_AST: - decode = estrdup("<ast>"); + case IS_CONSTANT_AST: { + zend_ast *ast = Z_ASTVAL_P(zv); + + if (ast->kind == ZEND_AST_CONSTANT + || ast->kind == ZEND_AST_CONSTANT_CLASS) { + decode = estrdup("<constant>"); + } else { + decode = estrdup("<ast>"); + } break; + } default: spprintf(&decode, 0, "unknown type: %d", Z_TYPE_P(zv)); break; diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c index 305a7daf2a..96504c7d7e 100644 --- a/sapi/phpdbg/phpdbg_wait.c +++ b/sapi/phpdbg/phpdbg_wait.c @@ -26,7 +26,7 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg) static void phpdbg_rebuild_http_globals_array(int type, const char *name) { zval *zvp; if (Z_TYPE(PG(http_globals)[type]) != IS_UNDEF) { - zval_dtor(&PG(http_globals)[type]); + zval_ptr_dtor_nogc(&PG(http_globals)[type]); } if ((zvp = zend_hash_str_find(&EG(symbol_table), name, strlen(name)))) { Z_ADDREF_P(zvp); @@ -327,7 +327,7 @@ void phpdbg_webdata_decompress(char *msg, int len) { } ZEND_HASH_FOREACH_END(); } - zval_dtor(&zv); + zval_ptr_dtor(&zv); if (free_zv) { /* separate freeing to not dtor the symtable too, just the container zval... */ efree(free_zv); diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index 8fa47ca1df..1d7f33ff6f 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -29,7 +29,7 @@ * WATCH_ON_HASHDATA: special watchpoint to watch for HT_GET_DATA_ADDR(ht) being efree()'d to be able to properly relocate Bucket watches * * Watch elements are either simple, recursive or implicit (PHPDBG_WATCH_* flags) - * Simple means that a particular watchpoint was explicitely defined + * Simple means that a particular watchpoint was explicitly defined * Recursive watch elements are created recursively (recursive root flag is to distinguish the root element easily from its children recursive elements) * Implicit watch elements are implicitely created on all ancestors of simple or recursive watch elements * Recursive and (simple or implicit) watch elements are mutually exclusive @@ -326,6 +326,7 @@ void phpdbg_watch_backup_data(phpdbg_watchpoint_t *watch) { zend_string_release(watch->backup.str); } watch->backup.str = zend_string_init((char *) watch->addr.ptr + XtOffsetOf(zend_string, val) - XtOffsetOf(zend_string, len), *(size_t *) watch->addr.ptr, 1); + GC_MAKE_PERSISTENT_LOCAL(watch->backup.str); break; case WATCH_ON_HASHTABLE: memcpy((char *) &watch->backup + HT_WATCH_OFFSET, watch->addr.ptr, watch->size); diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.c b/sapi/phpdbg/phpdbg_webdata_transfer.c index ed0a853709..a543f98ba7 100644 --- a/sapi/phpdbg/phpdbg_webdata_transfer.c +++ b/sapi/phpdbg/phpdbg_webdata_transfer.c @@ -27,7 +27,7 @@ static int phpdbg_is_auto_global(char *name, int len) { return ret; } -PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len) { +PHPDBG_API void phpdbg_webdata_compress(char **msg, size_t *len) { zval array; HashTable *ht; zval zv[9] = {{{0}}}; @@ -171,5 +171,5 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len) { *len = ZSTR_LEN(buf.s); } - zval_dtor(&array); + zend_array_destroy(Z_ARR(array)); } diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.h b/sapi/phpdbg/phpdbg_webdata_transfer.h index 3a55fbe10f..aa736a78b9 100644 --- a/sapi/phpdbg/phpdbg_webdata_transfer.h +++ b/sapi/phpdbg/phpdbg_webdata_transfer.h @@ -22,6 +22,6 @@ #include "zend.h" #include "phpdbg.h" -PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len); +PHPDBG_API void phpdbg_webdata_compress(char **msg, size_t *len); #endif /* PHPDBG_WEBDATA_TRANSFER_H */ diff --git a/sapi/phpdbg/tests/basic_run.phpt b/sapi/phpdbg/tests/basic_run.phpt index beb19b535a..130dc14110 100644 --- a/sapi/phpdbg/tests/basic_run.phpt +++ b/sapi/phpdbg/tests/basic_run.phpt @@ -3,6 +3,6 @@ Basic run --PHPDBG-- r q ---EXPECTF-- +--EXPECT-- prompt> [Nothing to execute!] prompt> diff --git a/sapi/phpdbg/tests/delimiter.phpt b/sapi/phpdbg/tests/delimiter.phpt index da5f681783..bf9cb598aa 100644 --- a/sapi/phpdbg/tests/delimiter.phpt +++ b/sapi/phpdbg/tests/delimiter.phpt @@ -2,6 +2,6 @@ Test # delimiter parsing and execution --PHPDBG-- ev 1 + 3 # ev 2 ** 3#q ---EXPECTF-- +--EXPECT-- prompt> 4 8 diff --git a/sapi/phpdbg/tests/exceptions_003.phpt b/sapi/phpdbg/tests/exceptions_003.phpt index 9d4abc0739..16920870c3 100644 --- a/sapi/phpdbg/tests/exceptions_003.phpt +++ b/sapi/phpdbg/tests/exceptions_003.phpt @@ -26,7 +26,7 @@ prompt> [L7 %s ECHO<1> "ok\n" 00009: } catch (Error $e) { prompt> ok [L7 %s FAST_RET ~%d try-catch(0) %s] -[L9 %s CATCH<-%d> "Error" $e 1 %s] +[L9 %s CATCH<%d> "Error" $e %s] >00005: x(); 00006: } finally { 00007: print "ok\n"; diff --git a/sapi/phpdbg/tests/info_002.phpt b/sapi/phpdbg/tests/info_002.phpt index faeca0e430..8b1aa0930c 100644 --- a/sapi/phpdbg/tests/info_002.phpt +++ b/sapi/phpdbg/tests/info_002.phpt @@ -13,11 +13,11 @@ prompt> [Breakpoint #0 at %s:10, hits: 1] 00011: prompt> [User-defined constants (2)] Address Refs Type Constant -%s 1 integer A +%s 1 int A int (10) -%s 1 integer B +%s 1 int B int (100) -prompt> +prompt> --FILE-- <?php diff --git a/sapi/phpdbg/tests/run_001.phpt b/sapi/phpdbg/tests/run_001.phpt index 30aab1f17a..626ecb323b 100644 --- a/sapi/phpdbg/tests/run_001.phpt +++ b/sapi/phpdbg/tests/run_001.phpt @@ -21,7 +21,7 @@ array(5) { string(1) "3" } [Script ended normally] -prompt> int(5) +prompt> int(4) array(4) { [0]=> string(%d) "%s" diff --git a/sapi/phpdbg/tests/stdin_001.phpt b/sapi/phpdbg/tests/stdin_001.phpt index 2f93a2d956..977e445045 100644 --- a/sapi/phpdbg/tests/stdin_001.phpt +++ b/sapi/phpdbg/tests/stdin_001.phpt @@ -11,7 +11,7 @@ r c r q ---EXPECTF-- +--EXPECT-- prompt> [Successful compilation of stdin input] prompt> [Breakpoint #0 added at Standard input code:3] prompt> [Breakpoint #0 at Standard input code:3, hits: 1] diff --git a/sapi/phpdbg/tests/stepping_001.phpt b/sapi/phpdbg/tests/stepping_001.phpt index e8e32db0be..90b2e5573a 100644 --- a/sapi/phpdbg/tests/stepping_001.phpt +++ b/sapi/phpdbg/tests/stepping_001.phpt @@ -25,7 +25,7 @@ prompt> [L0 %s HANDLE_EXCEPTION 00005: } 00006: prompt> [L0 %s HANDLE_EXCEPTION %s] -[L9 %s CATCH<-%d> "Exception" $e 1 %s] +[L9 %s CATCH<%d> "Exception" $e %s] >00008: foo(); 00009: } catch (Exception $e) { 00010: echo "ok"; diff --git a/sapi/phpdbg/travis/ci.sh b/sapi/phpdbg/travis/ci.sh deleted file mode 100755 index 206b158b9b..0000000000 --- a/sapi/phpdbg/travis/ci.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env sh -git clone https://github.com/php/php-src -cd php-src -git checkout $PHP -cd sapi -rm -rf phpdbg -git clone https://github.com/krakjoe/phpdbg.git -cd ../ -./buildconf --force -./configure --disable-all --enable-phpdbg --enable-maintainer-zts -make |
