File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -466,7 +466,7 @@ static ssize_t zlog_stream_buf_flush(struct zlog_stream *stream) /* {{{ */
466466 }
467467#endif
468468
469- if (external_logger != NULL ) {
469+ if (stream -> use_external_logger ) {
470470 external_logger (stream -> flags & ZLOG_LEVEL_MASK ,
471471 stream -> buf .data + stream -> prefix_len , stream -> len - stream -> prefix_len );
472472 }
@@ -539,9 +539,11 @@ static inline void zlog_stream_init_internal(
539539 stream -> fd = fd > -1 ? fd : STDERR_FILENO ;
540540 stream -> buf_init_size = capacity ;
541541 if (flags & ZLOG_ACCESS_LOG ) {
542+ stream -> use_external_logger = 0 ;
542543 stream -> use_buffer = 1 ;
543544 stream -> use_stderr = fd < 0 ;
544545 } else {
546+ stream -> use_external_logger = external_logger != NULL ;
545547 stream -> use_buffer = zlog_buffering || external_logger != NULL || stream -> use_syslog ;
546548 stream -> use_stderr = fd < 0 ||
547549 (
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ struct zlog_stream {
7777 unsigned int decorate :1 ;
7878 unsigned int is_stdout :1 ;
7979 unsigned int over_limit :1 ;
80+ unsigned int use_external_logger :1 ;
8081 int fd ;
8182 int line ;
8283 int child_pid ;
Original file line number Diff line number Diff line change 1+ --TEST--
2+ FPM: GH-19989 - Access log going to fcgi error stream
3+ --SKIPIF--
4+ <?php include "skipif.inc " ; ?>
5+ --FILE--
6+ <?php
7+
8+ require_once "tester.inc " ;
9+
10+ $ src = <<<EOT
11+ <?php
12+ echo "OK";
13+ EOT ;
14+
15+ $ cfg = <<<EOT
16+ [global]
17+ error_log = {{RFILE:LOG:ERR}}
18+ pid = {{RFILE:PID}}
19+ [unconfined]
20+ listen = {{ADDR}}
21+ access.log = {{RFILE:LOG:ACC}}
22+ access.format = "'%m %r%Q%q' %s"
23+ pm = static
24+ pm.max_children = 2
25+ EOT ;
26+
27+ $ prefix = __DIR__ ;
28+ $ tester = new FPM \Tester ($ cfg , $ src );
29+ $ tester ->start (['--prefix ' , $ prefix ]);
30+ $ tester ->expectLogStartNotices ();
31+ $ response = $ tester ->request ()->expectBody ('OK ' );
32+ $ response ->expectNoError ();
33+ $ tester ->expectAccessLog ("'GET /gh19989-access-log-fcgi-stderr.src.php' 200 " );
34+ $ tester ->terminate ();
35+ $ tester ->expectLogTerminatingNotices ();
36+ $ tester ->close ();
37+ $ tester ->checkAccessLog ();
38+
39+ ?>
40+ Done
41+ --EXPECT--
42+ Done
43+ --CLEAN--
44+ <?php
45+ require_once "tester.inc " ;
46+ FPM \Tester::clean ();
47+ ?>
You can’t perform that action at this time.
0 commit comments