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

Commita214e9c

Browse files
committed
Fix problem with infinite recursion between write_syslogger_file and
elog if the former has trouble writing its file. Code review forMagnus' patch to redirect stderr to syslog on Windows (Bruce's versionseems right, but did some minor prettification).Backpatch both changes to 8.0 branch.
1 parentb9de4a2 commita214e9c

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

‎src/backend/postmaster/syslogger.c

Lines changed: 3 additions & 4 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.13 2005/03/10 07:14:03 neilc Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.14 2005/03/12 01:54:44 tgl Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -679,10 +679,9 @@ write_syslogger_file_binary(const char *buffer, int count)
679679
LeaveCriticalSection(&sysfileSection);
680680
#endif
681681

682+
/* can't use ereport here because of possible recursion */
682683
if (rc!=count)
683-
ereport(LOG,
684-
(errcode_for_file_access(),
685-
errmsg("could not write to log file: %m")));
684+
write_stderr("could not write to log file: %s\n",strerror(errno));
686685
}
687686

688687
#ifdefWIN32

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

Lines changed: 12 additions & 7 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.157 2005/02/27 01:02:57 momjian Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.158 2005/03/12 01:54:44 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1557,7 +1557,6 @@ send_message_to_server_log(ErrorData *edata)
15571557
appendStringInfoChar(&buf,'\n');
15581558
}
15591559

1560-
15611560
#ifdefHAVE_SYSLOG
15621561
/* Write to syslog, if enabled */
15631562
if (Log_destination&LOG_DESTINATION_SYSLOG)
@@ -1597,7 +1596,9 @@ send_message_to_server_log(ErrorData *edata)
15971596
write_syslog(syslog_level,buf.data);
15981597
}
15991598
#endif/* HAVE_SYSLOG */
1599+
16001600
#ifdefWIN32
1601+
/* Write to eventlog, if enabled */
16011602
if (Log_destination&LOG_DESTINATION_EVENTLOG)
16021603
{
16031604
inteventlog_level;
@@ -1628,19 +1629,23 @@ send_message_to_server_log(ErrorData *edata)
16281629
write_eventlog(eventlog_level,buf.data);
16291630
}
16301631
#endif/* WIN32 */
1632+
16311633
/* Write to stderr, if enabled */
16321634
if ((Log_destination&LOG_DESTINATION_STDERR)||whereToSendOutput==Debug)
16331635
{
16341636
#ifdefWIN32
1635-
/* In a win32 service environment, there is no usable stderr. Capture
1636-
anything going there and write it to the eventlog instead.
1637-
If stderr redirection is active, leave it to stderr because the
1638-
logger will capture it to a file. */
1637+
/*
1638+
* In a win32 service environment, there is no usable stderr. Capture
1639+
* anything going there and write it to the eventlog instead.
1640+
*
1641+
* If stderr redirection is active, it's ok to write to stderr
1642+
* because that's really a pipe to the syslogger process.
1643+
*/
16391644
if ((!Redirect_stderr||am_syslogger)&&pgwin32_is_service())
16401645
write_eventlog(EVENTLOG_ERROR_TYPE,buf.data);
16411646
else
16421647
#endif
1643-
fprintf(stderr,"%s",buf.data);
1648+
fprintf(stderr,"%s",buf.data);
16441649
}
16451650

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp