From e254eecb774e87c8a6e06e5997d9cc62a37c9e71 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Fri, 16 Mar 2018 18:19:48 +0300 Subject: PHP: fixed segfault on initialization. PHP SAPI can call log handler while initializing. Particularly, that happens if there's a problem in loading some extension specified in php.ini file. On this stage server context is empty, so now nxt_thread_log_error() is used. --- src/nxt_php_sapi.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/nxt_php_sapi.c') diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index c4e5fe1c..b7c68760 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -38,11 +38,11 @@ static int nxt_php_startup(sapi_module_struct *sapi_module); static int nxt_php_send_headers(sapi_headers_struct *sapi_headers); static char *nxt_php_read_cookies(void); static void nxt_php_register_variables(zval *track_vars_array); -static void nxt_php_log_message(char *message #ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE - , int syslog_type_int +static void nxt_php_log_message(char *message, int syslog_type_int); +#else +static void nxt_php_log_message(char *message); #endif -); #ifdef NXT_PHP7 static size_t nxt_php_unbuffered_write(const char *str, @@ -766,16 +766,13 @@ nxt_php_register_variables(zval *track_vars_array TSRMLS_DC) } -static void -nxt_php_log_message(char *message #ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE - , int syslog_type_int +static void +nxt_php_log_message(char *message, int syslog_type_int) +#else +static void +nxt_php_log_message(char *message) #endif -) { - nxt_php_run_ctx_t *ctx; - - ctx = SG(server_context); - - nxt_log(ctx->task, NXT_LOG_NOTICE, "php message: %s", message); + nxt_thread_log_error(NXT_LOG_NOTICE, "php message: %s", message); } -- cgit