aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/postmaster/postmaster.c13
-rw-r--r--src/backend/postmaster/syslogger.c9
-rw-r--r--src/backend/utils/error/elog.c12
3 files changed, 21 insertions, 13 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 9672c3bc06d..42cb240260f 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.505.2.3 2007/02/11 15:12:21 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.505.2.4 2007/07/19 19:14:25 adunstan Exp $
*
* NOTES
*
@@ -202,8 +202,8 @@ static pid_t StartupPID = 0,
BgWriterPID = 0,
AutoVacPID = 0,
PgArchPID = 0,
- PgStatPID = 0;
-pid_t SysLoggerPID = 0; /* Needs to be accessed from elog.c */
+ PgStatPID = 0,
+ SysLoggerPID = 0;
/* Startup/shutdown state */
#define NoShutdown 0
@@ -217,6 +217,8 @@ static bool FatalError = false; /* T if recovering from backend crash */
bool ClientAuthInProgress = false; /* T during new-client
* authentication */
+bool redirection_done = false;
+
static bool force_autovac = false; /* received START_AUTOVAC signal */
/*
@@ -328,6 +330,7 @@ typedef struct
InheritableSocket pgStatSock;
pid_t PostmasterPid;
TimestampTz PgStartTime;
+ bool redirection_done;
#ifdef WIN32
HANDLE PostmasterHandle;
HANDLE initial_signal_pipe;
@@ -3822,6 +3825,8 @@ save_backend_variables(BackendParameters * param, Port *port,
param->PostmasterPid = PostmasterPid;
param->PgStartTime = PgStartTime;
+ param->redirection_done = redirection_done;
+
#ifdef WIN32
param->PostmasterHandle = PostmasterHandle;
write_duplicated_handle(&param->initial_signal_pipe,
@@ -4025,6 +4030,8 @@ restore_backend_variables(BackendParameters * param, Port *port)
PostmasterPid = param->PostmasterPid;
PgStartTime = param->PgStartTime;
+ redirection_done = param->redirection_done;
+
#ifdef WIN32
PostmasterHandle = param->PostmasterHandle;
pgwin32_initial_signal_pipe = param->initial_signal_pipe;
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 96c4cf130d5..110bec9f78e 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -18,7 +18,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.29.2.1 2007/06/14 01:49:39 adunstan Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.29.2.2 2007/07/19 19:14:25 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,11 +79,12 @@ bool Log_truncate_on_rotation = false;
*/
bool am_syslogger = false;
+extern bool redirection_done;
+
/*
* Private state
*/
static pg_time_t next_rotation_time;
-static bool redirection_done = false;
static bool pipe_eof_seen = false;
static FILE *syslogFile = NULL;
static char *last_file_name = NULL;
@@ -583,14 +584,12 @@ syslogger_forkexec(void)
snprintf(numbuf[bufc++], 32, "%d", fileno(syslogFile));
else
strcpy(numbuf[bufc++], "-1");
- snprintf(numbuf[bufc++], 32, "%d", (int) redirection_done);
#else /* WIN32 */
if (syslogFile != NULL)
snprintf(numbuf[bufc++], 32, "%ld",
_get_osfhandle(_fileno(syslogFile)));
else
strcpy(numbuf[bufc++], "0");
- snprintf(numbuf[bufc++], 32, "%d", (int) redirection_done);
#endif /* WIN32 */
/* Add to the arg list */
@@ -624,7 +623,6 @@ syslogger_parseArgs(int argc, char *argv[])
syslogFile = fdopen(fd, "a");
setvbuf(syslogFile, NULL, LBF_MODE, 0);
}
- redirection_done = (bool) atoi(*argv++);
#else /* WIN32 */
fd = atoi(*argv++);
if (fd != 0)
@@ -636,7 +634,6 @@ syslogger_parseArgs(int argc, char *argv[])
setvbuf(syslogFile, NULL, LBF_MODE, 0);
}
}
- redirection_done = (bool) atoi(*argv++);
#endif /* WIN32 */
}
#endif /* EXEC_BACKEND */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 49771ae349a..f835b21ef9c 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -42,7 +42,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.178.2.2 2007/06/14 01:49:39 adunstan Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.178.2.3 2007/07/19 19:14:25 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
@@ -76,7 +76,7 @@ ErrorContextCallback *error_context_stack = NULL;
sigjmp_buf *PG_exception_stack = NULL;
-extern pid_t SysLoggerPID;
+extern bool redirection_done;
/* GUC parameters */
PGErrorVerbosity Log_error_verbosity = PGERROR_VERBOSE;
@@ -1720,11 +1720,15 @@ send_message_to_server_log(ErrorData *edata)
* that's really a pipe to the syslogger process. Unless we're in the
* postmaster, and the syslogger process isn't started yet.
*/
- if ((!Redirect_stderr || am_syslogger || (!IsUnderPostmaster && SysLoggerPID==0)) && pgwin32_is_service())
+ if (pgwin32_is_service() && (!redirection_done || am_syslogger) )
write_eventlog(edata->elevel, buf.data);
else
#endif
- if (Redirect_stderr)
+ /* only use the chunking protocol if we know the syslogger should
+ * be catching stderr output, and we are not ourselves the
+ * syslogger. Otherwise, go directly to stderr.
+ */
+ if (redirection_done && !am_syslogger)
write_pipe_chunks(fileno(stderr), buf.data, buf.len);
else
write(fileno(stderr), buf.data, buf.len);