Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0e5b4f0

Browse files
committed
Only use the pipe chunking protocol if we know the syslogger should
be catching stderr output, and we are not ourselves thesyslogger. Otherwise, go directly to stderr.Bug noticed by Tom Lane.Backpatch as far as 8.0.
1 parent177be3f commit0e5b4f0

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.532 2007/07/11 08:27:33 mha Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.533 2007/07/19 19:13:43 adunstan Exp $
4141
*
4242
* NOTES
4343
*
@@ -203,8 +203,8 @@ static pid_t StartupPID = 0,
203203
BgWriterPID=0,
204204
AutoVacPID=0,
205205
PgArchPID=0,
206-
PgStatPID=0;
207-
pid_tSysLoggerPID=0;/* Needs to be accessed from elog.c */
206+
PgStatPID=0,
207+
SysLoggerPID=0;
208208

209209
/* Startup/shutdown state */
210210
#defineNoShutdown0
@@ -218,6 +218,8 @@ static bool FatalError = false; /* T if recovering from backend crash */
218218
boolClientAuthInProgress= false;/* T during new-client
219219
* authentication */
220220

221+
boolredirection_done= false;
222+
221223
/* received START_AUTOVAC_LAUNCHER signal */
222224
staticboolstart_autovac_launcher= false;
223225

@@ -332,6 +334,7 @@ typedef struct
332334
InheritableSocketpgStatSock;
333335
pid_tPostmasterPid;
334336
TimestampTzPgStartTime;
337+
boolredirection_done;
335338
#ifdefWIN32
336339
HANDLEPostmasterHandle;
337340
HANDLEinitial_signal_pipe;
@@ -3953,6 +3956,8 @@ save_backend_variables(BackendParameters * param, Port *port,
39533956
param->PostmasterPid=PostmasterPid;
39543957
param->PgStartTime=PgStartTime;
39553958

3959+
param->redirection_done=redirection_done;
3960+
39563961
#ifdefWIN32
39573962
param->PostmasterHandle=PostmasterHandle;
39583963
write_duplicated_handle(&param->initial_signal_pipe,
@@ -4156,6 +4161,8 @@ restore_backend_variables(BackendParameters * param, Port *port)
41564161
PostmasterPid=param->PostmasterPid;
41574162
PgStartTime=param->PgStartTime;
41584163

4164+
redirection_done=param->redirection_done;
4165+
41594166
#ifdefWIN32
41604167
PostmasterHandle=param->PostmasterHandle;
41614168
pgwin32_initial_signal_pipe=param->initial_signal_pipe;

‎src/backend/postmaster/syslogger.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.32 2007/06/14 01:48:51 adunstan Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.33 2007/07/19 19:13:43 adunstan Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -79,11 +79,12 @@ boolLog_truncate_on_rotation = false;
7979
*/
8080
boolam_syslogger= false;
8181

82+
externboolredirection_done;
83+
8284
/*
8385
* Private state
8486
*/
8587
staticpg_time_tnext_rotation_time;
86-
staticboolredirection_done= false;
8788
staticboolpipe_eof_seen= false;
8889
staticFILE*syslogFile=NULL;
8990
staticchar*last_file_name=NULL;
@@ -582,14 +583,12 @@ syslogger_forkexec(void)
582583
snprintf(numbuf[bufc++],32,"%d",fileno(syslogFile));
583584
else
584585
strcpy(numbuf[bufc++],"-1");
585-
snprintf(numbuf[bufc++],32,"%d", (int)redirection_done);
586586
#else/* WIN32 */
587587
if (syslogFile!=NULL)
588588
snprintf(numbuf[bufc++],32,"%ld",
589589
_get_osfhandle(_fileno(syslogFile)));
590590
else
591591
strcpy(numbuf[bufc++],"0");
592-
snprintf(numbuf[bufc++],32,"%d", (int)redirection_done);
593592
#endif/* WIN32 */
594593

595594
/* Add to the arg list */
@@ -623,7 +622,6 @@ syslogger_parseArgs(int argc, char *argv[])
623622
syslogFile=fdopen(fd,"a");
624623
setvbuf(syslogFile,NULL,LBF_MODE,0);
625624
}
626-
redirection_done= (bool)atoi(*argv++);
627625
#else/* WIN32 */
628626
fd=atoi(*argv++);
629627
if (fd!=0)
@@ -635,7 +633,6 @@ syslogger_parseArgs(int argc, char *argv[])
635633
setvbuf(syslogFile,NULL,LBF_MODE,0);
636634
}
637635
}
638-
redirection_done= (bool)atoi(*argv++);
639636
#endif/* WIN32 */
640637
}
641638
#endif/* EXEC_BACKEND */

‎src/backend/utils/error/elog.c

Lines changed: 8 additions & 4 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.187 2007/06/14 01:48:51 adunstan Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.188 2007/07/19 19:13:43 adunstan Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -76,7 +76,7 @@ ErrorContextCallback *error_context_stack = NULL;
7676

7777
sigjmp_buf*PG_exception_stack=NULL;
7878

79-
externpid_tSysLoggerPID;
79+
externboolredirection_done;
8080

8181
/* GUC parameters */
8282
PGErrorVerbosityLog_error_verbosity=PGERROR_VERBOSE;
@@ -1780,11 +1780,15 @@ send_message_to_server_log(ErrorData *edata)
17801780
* that's really a pipe to the syslogger process. Unless we're in the
17811781
* postmaster, and the syslogger process isn't started yet.
17821782
*/
1783-
if ((!Redirect_stderr||am_syslogger||(!IsUnderPostmaster&&SysLoggerPID==0))&&pgwin32_is_service())
1783+
if (pgwin32_is_service()&& (!redirection_done||am_syslogger))
17841784
write_eventlog(edata->elevel,buf.data);
17851785
else
17861786
#endif
1787-
if (Redirect_stderr)
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)
17881792
write_pipe_chunks(fileno(stderr),buf.data,buf.len);
17891793
else
17901794
write(fileno(stderr),buf.data,buf.len);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp