Skip to content

Commit 8e1a8fe

Browse files
committed
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.
1 parent 029348c commit 8e1a8fe

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/backend/postmaster/syslogger.c

Lines changed: 7 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.49 2009/02/24 12:09:09 petere Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.50 2009/03/18 08:44:49 heikki Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -907,13 +907,14 @@ write_syslogger_file(const char *buffer, int count, int destination)
907907
if (destination == LOG_DESTINATION_CSVLOG && csvlogFile == NULL)
908908
open_csvlogfile();
909909

910-
logfile = destination == LOG_DESTINATION_CSVLOG ? csvlogFile : syslogFile;
911-
912-
#ifndef WIN32
913-
rc = fwrite(buffer, 1, count, logfile);
914-
#else
910+
#ifdef WIN32
915911
EnterCriticalSection(&sysfileSection);
912+
#endif
913+
914+
logfile = destination == LOG_DESTINATION_CSVLOG ? csvlogFile : syslogFile;
916915
rc = fwrite(buffer, 1, count, logfile);
916+
917+
#ifdef WIN32
917918
LeaveCriticalSection(&sysfileSection);
918919
#endif
919920

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy