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.
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