mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
Fix problem with infinite recursion between write_syslogger_file and
elog if the former has trouble writing its file. Code review for Magnus' patch to redirect stderr to syslog on Windows (Bruce's version seems right, but did some minor prettification). Backpatch both changes to 8.0 branch.
This commit is contained in:
parent
b9de4a26cf
commit
a214e9c996
src/backend
@ -18,7 +18,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.13 2005/03/10 07:14:03 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.14 2005/03/12 01:54:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -679,10 +679,9 @@ write_syslogger_file_binary(const char *buffer, int count)
|
|||||||
LeaveCriticalSection(&sysfileSection);
|
LeaveCriticalSection(&sysfileSection);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* can't use ereport here because of possible recursion */
|
||||||
if (rc != count)
|
if (rc != count)
|
||||||
ereport(LOG,
|
write_stderr("could not write to log file: %s\n", strerror(errno));
|
||||||
(errcode_for_file_access(),
|
|
||||||
errmsg("could not write to log file: %m")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.157 2005/02/27 01:02:57 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.158 2005/03/12 01:54:44 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1557,7 +1557,6 @@ send_message_to_server_log(ErrorData *edata)
|
|||||||
appendStringInfoChar(&buf, '\n');
|
appendStringInfoChar(&buf, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
/* Write to syslog, if enabled */
|
/* Write to syslog, if enabled */
|
||||||
if (Log_destination & LOG_DESTINATION_SYSLOG)
|
if (Log_destination & LOG_DESTINATION_SYSLOG)
|
||||||
@ -1597,7 +1596,9 @@ send_message_to_server_log(ErrorData *edata)
|
|||||||
write_syslog(syslog_level, buf.data);
|
write_syslog(syslog_level, buf.data);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SYSLOG */
|
#endif /* HAVE_SYSLOG */
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
/* Write to eventlog, if enabled */
|
||||||
if (Log_destination & LOG_DESTINATION_EVENTLOG)
|
if (Log_destination & LOG_DESTINATION_EVENTLOG)
|
||||||
{
|
{
|
||||||
int eventlog_level;
|
int eventlog_level;
|
||||||
@ -1628,19 +1629,23 @@ send_message_to_server_log(ErrorData *edata)
|
|||||||
write_eventlog(eventlog_level, buf.data);
|
write_eventlog(eventlog_level, buf.data);
|
||||||
}
|
}
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
/* Write to stderr, if enabled */
|
/* Write to stderr, if enabled */
|
||||||
if ((Log_destination & LOG_DESTINATION_STDERR) || whereToSendOutput == Debug)
|
if ((Log_destination & LOG_DESTINATION_STDERR) || whereToSendOutput == Debug)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/* In a win32 service environment, there is no usable stderr. Capture
|
/*
|
||||||
anything going there and write it to the eventlog instead.
|
* In a win32 service environment, there is no usable stderr. Capture
|
||||||
If stderr redirection is active, leave it to stderr because the
|
* anything going there and write it to the eventlog instead.
|
||||||
logger will capture it to a file. */
|
*
|
||||||
|
* If stderr redirection is active, it's ok to write to stderr
|
||||||
|
* because that's really a pipe to the syslogger process.
|
||||||
|
*/
|
||||||
if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service())
|
if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service())
|
||||||
write_eventlog(EVENTLOG_ERROR_TYPE, buf.data);
|
write_eventlog(EVENTLOG_ERROR_TYPE, buf.data);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "%s", buf.data);
|
fprintf(stderr, "%s", buf.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If in the syslogger process, try to write messages direct to file */
|
/* If in the syslogger process, try to write messages direct to file */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user