diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-03-18 08:44:52 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-03-18 08:44:52 +0000 |
commit | 06ce04ab18f8061b035dabbdee7b0bb793ac3200 (patch) | |
tree | 1eb009635c6b7b56e084fc0293b2401becd7f017 /src | |
parent | 6cc0e006ee613896623065195fef8a556181da6d (diff) |
Fix Windows-specific race condition in syslogger. This could've been
the cause of the "could not write to log file: Bad file descriptor"
errors reported at
http://archives.postgresql.org//pgsql-general/2008-06/msg00193.php
Backpatch to 8.3, the race condition was introduced by the CSV logging
patch.
Analysis and patch by Gurjeet Singh.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/postmaster/syslogger.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index aa5d34ef5b2..39006466b2d 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.44 2008/01/25 20:42:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.44.2.1 2009/03/18 08:44:52 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -909,13 +909,14 @@ write_syslogger_file(const char *buffer, int count, int destination) if (destination == LOG_DESTINATION_CSVLOG && csvlogFile == NULL) open_csvlogfile(); - logfile = destination == LOG_DESTINATION_CSVLOG ? csvlogFile : syslogFile; - -#ifndef WIN32 - rc = fwrite(buffer, 1, count, logfile); -#else +#ifdef WIN32 EnterCriticalSection(&sysfileSection); +#endif + + logfile = destination == LOG_DESTINATION_CSVLOG ? csvlogFile : syslogFile; rc = fwrite(buffer, 1, count, logfile); + +#ifdef WIN32 LeaveCriticalSection(&sysfileSection); #endif |