summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2018-03-16 18:19:48 +0300
committerValentin Bartenev <vbart@nginx.com>2018-03-16 18:19:48 +0300
commite254eecb774e87c8a6e06e5997d9cc62a37c9e71 (patch)
tree43bf79d9189d32e0e39a97113fa1d27515928a34
parentf0df93ee3bb59923505e34c6b302fb2b7325ee80 (diff)
downloadunit-e254eecb774e87c8a6e06e5997d9cc62a37c9e71.tar.gz
unit-e254eecb774e87c8a6e06e5997d9cc62a37c9e71.tar.bz2
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.
-rw-r--r--src/nxt_php_sapi.c21
1 files changed, 9 insertions, 12 deletions
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);
}