]> granicus.if.org Git - php/commitdiff
- Fixed bug #52693 (configuration file errors are not logged to stderr)
authorJérôme Loyet <fat@php.net>
Thu, 11 Nov 2010 22:48:46 +0000 (22:48 +0000)
committerJérôme Loyet <fat@php.net>
Thu, 11 Nov 2010 22:48:46 +0000 (22:48 +0000)
sapi/fpm/fpm/fpm.c
sapi/fpm/fpm/fpm_stdio.c
sapi/fpm/fpm/fpm_unix.c
sapi/fpm/fpm/zlog.c
sapi/fpm/fpm/zlog.h

index eb0c7351d568a89da35043db059f50da4beb0a9c..fd4617350e53122678ff9037ae2efad8f57851a2 100644 (file)
@@ -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;
index 235974454305d539ce5c38857b35753dcc17686d..e6ecf1a6b54c1a1c0ab279e7fbf5f80308fc36bf 100644 (file)
@@ -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;
index 5e263c7dd51cba428c3844f07190e3677505a81c..d63ea4d5b01fc4b54fd7187f8c533ca2d538fbca 100644 (file)
@@ -246,7 +246,7 @@ int fpm_unix_init_main() /* {{{ */
                }
        }
 
-       fpm_stdio_init_final();
+       zlog_set_level(fpm_globals.log_level);
        return 0;
 }
 /* }}} */
index 1f70c450923967452a582feb323ed23ef7f05ab1..66e58762ed9d82d2638925b8ca00e00d0aac2aff 100644 (file)
@@ -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);
+       }
 }
 /* }}} */
 
index 087fa0e4e5c807c191bc2ba2d2dea95b653a97df..fbb34ee6f69c8c9563c6b0221245ab95cb37d757 100644 (file)
@@ -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);