Skip to content

Commit f812dd9

Browse files
committed
On second thought, the tests for what to do with stderr output are a
lot more sensible if we check the chunk-output case first. Not back-patched since it's just a cosmetic improvement.
1 parent 4ca7a2d commit f812dd9

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/backend/utils/error/elog.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.188 2007/07/19 19:13:43 adunstan Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.189 2007/07/19 21:58:12 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1770,28 +1770,26 @@ send_message_to_server_log(ErrorData *edata)
17701770
/* Write to stderr, if enabled */
17711771
if ((Log_destination & LOG_DESTINATION_STDERR) || whereToSendOutput == DestDebug)
17721772
{
1773+
/*
1774+
* Use the chunking protocol if we know the syslogger should
1775+
* be catching stderr output, and we are not ourselves the
1776+
* syslogger. Otherwise, just do a vanilla write to stderr.
1777+
*/
1778+
if (redirection_done && !am_syslogger)
1779+
write_pipe_chunks(fileno(stderr), buf.data, buf.len);
17731780
#ifdef WIN32
1774-
17751781
/*
17761782
* In a win32 service environment, there is no usable stderr. Capture
17771783
* anything going there and write it to the eventlog instead.
17781784
*
1779-
* If stderr redirection is active, it's ok to write to stderr because
1780-
* that's really a pipe to the syslogger process. Unless we're in the
1781-
* postmaster, and the syslogger process isn't started yet.
1785+
* If stderr redirection is active, it was OK to write to stderr above
1786+
* because that's really a pipe to the syslogger process.
17821787
*/
1783-
if (pgwin32_is_service() && (!redirection_done || am_syslogger) )
1788+
else if (pgwin32_is_service())
17841789
write_eventlog(edata->elevel, buf.data);
1785-
else
17861790
#endif
1787-
/* only use the chunking protocol if we know the syslogger should
1788-
* be catching stderr output, and we are not ourselves the
1789-
* syslogger. Otherwise, go directly to stderr.
1790-
*/
1791-
if (redirection_done && !am_syslogger)
1792-
write_pipe_chunks(fileno(stderr), buf.data, buf.len);
1793-
else
1794-
write(fileno(stderr), buf.data, buf.len);
1791+
else
1792+
write(fileno(stderr), buf.data, buf.len);
17951793
}
17961794

17971795
/* If in the syslogger process, try to write messages direct to file */

0 commit comments

Comments
 (0)