From: Jérôme Loyet Date: Thu, 11 Nov 2010 22:48:46 +0000 (+0000) Subject: - Fixed bug #52693 (configuration file errors are not logged to stderr) X-Git-Tag: php-5.3.4RC1~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da29092159d1681951126da62b926b5cfb6daf10;p=php - Fixed bug #52693 (configuration file errors are not logged to stderr) --- diff --git a/NEWS b/NEWS index 8f170221b9..504d730de7 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,7 @@ - Fixed the filter extension accepting IPv4 octets with a leading 0 as that belongs to the unsupported "dotted octal" representation. (Gustavo) +- Fixed bug #52693 (configuration file errors are not logged to stderr). (fat) - Fixed bug #53279 (SplFileObject doesn't initialise default CSV escape character). (Adam) - Fixed bug #53273 (mb_strcut() returns garbage with the excessive length diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index eb0c7351d5..fd4617350e 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -47,6 +47,7 @@ int fpm_init(int argc, char **argv, char *config, struct event_base **base) /* { return -1; } + fpm_stdio_init_final(); zlog(ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid); return 0; diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c index 2359744543..e6ecf1a6b5 100644 --- a/sapi/fpm/fpm/fpm_stdio.c +++ b/sapi/fpm/fpm/fpm_stdio.c @@ -41,7 +41,6 @@ int fpm_stdio_init_main() /* {{{ */ int fpm_stdio_init_final() /* {{{ */ { - zlog_set_level(fpm_globals.log_level); if (fpm_global_config.daemonize) { if (fpm_globals.error_log_fd != STDERR_FILENO) { /* there might be messages to stderr from libevent, we need to log them all */ @@ -50,8 +49,8 @@ int fpm_stdio_init_final() /* {{{ */ return -1; } } - zlog_set_fd(fpm_globals.error_log_fd); } + zlog_set_launched(); return 0; } /* }}} */ @@ -251,6 +250,9 @@ int fpm_stdio_open_error_log(int reopen) /* {{{ */ fd = fpm_globals.error_log_fd; /* for FD_CLOSEXEC to work */ } else { fpm_globals.error_log_fd = fd; + if (fpm_global_config.daemonize) { + zlog_set_fd(fpm_globals.error_log_fd); + } } fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); return 0; diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c index 5e263c7dd5..d63ea4d5b0 100644 --- a/sapi/fpm/fpm/fpm_unix.c +++ b/sapi/fpm/fpm/fpm_unix.c @@ -246,7 +246,7 @@ int fpm_unix_init_main() /* {{{ */ } } - fpm_stdio_init_final(); + zlog_set_level(fpm_globals.log_level); return 0; } /* }}} */ diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c index 1f70c45092..66e58762ed 100644 --- a/sapi/fpm/fpm/zlog.c +++ b/sapi/fpm/fpm/zlog.c @@ -18,6 +18,7 @@ static int zlog_fd = -1; static int zlog_level = ZLOG_NOTICE; +static int launched = 0; static const char *level_names[] = { [ZLOG_DEBUG] = "DEBUG", @@ -27,6 +28,10 @@ static const char *level_names[] = { [ZLOG_ALERT] = "ALERT", }; +void zlog_set_launched(void) { + launched = 1; +} + size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len) /* {{{ */ { struct tm t; @@ -110,6 +115,9 @@ void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) /* buf[len++] = '\n'; write(zlog_fd > -1 ? zlog_fd : STDERR_FILENO, buf, len); + if (zlog_fd != STDERR_FILENO && zlog_fd > -1 && !launched && (flags & ZLOG_LEVEL_MASK) >= ZLOG_WARNING) { + write(STDERR_FILENO, buf, len); + } } /* }}} */ diff --git a/sapi/fpm/fpm/zlog.h b/sapi/fpm/fpm/zlog.h index 087fa0e4e5..fbb34ee6f6 100644 --- a/sapi/fpm/fpm/zlog.h +++ b/sapi/fpm/fpm/zlog.h @@ -11,6 +11,7 @@ struct timeval; int zlog_set_fd(int new_fd); int zlog_set_level(int new_value); +void zlog_set_launched(void); size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len);