use binary mode on syslog pipe on windows to avoid upsetting chunking protocol
This small patch makes the syslog pipe use binary mode on Windows so
that CRLF translation (and possibly other oddities) don't upset the pipe
chunking protocol. It preserves text mode for the redirected syslog
file, as recently discussed on -hackers, so there should be no visible
change.
If there is no objection I will apply this and backport it to 8.0 shortly.
cheers
andrew
Attachments:
crlf2.patchtext/x-patch; name=crlf2.patchDownload+14-4
Andrew Dunstan <andrew@dunslane.net> writes:
This small patch makes the syslog pipe use binary mode on Windows
You need to think harder about where you are inserting the additions,
as these choices seem a bit random. For instance here:
/* On Windows, need to interlock against data-transfer thread */
#ifdef WIN32
+ _setmode(_fileno(fh), _O_TEXT); /* use CRLF line endings on Windows */
EnterCriticalSection(&sysfileSection);
#endif
fclose(syslogFile);
you have inserted a 100% unrelated action between a comment and the
statement it describes. How readable will this code be to the next
person? Far better to expend an additional #ifdef/#endif pair, if
needed, to put the call either by itself or with some code that it's
sensibly related to. Being "WIN32" is not sufficient connection.
regards, tom lane
Tom Lane wrote:
Andrew Dunstan <andrew@dunslane.net> writes:
This small patch makes the syslog pipe use binary mode on Windows
You need to think harder about where you are inserting the additions,
as these choices seem a bit random.
Is this more to your taste?
cheers
andrew
Attachments:
crlf3.patchtext/x-patch; name=crlf3.patchDownload+34-4
Andrew Dunstan wrote:
Tom Lane wrote:
Andrew Dunstan <andrew@dunslane.net> writes:
This small patch makes the syslog pipe use binary mode on Windows
You need to think harder about where you are inserting the additions,
as these choices seem a bit random.Is this more to your taste?
... and yes I'll fix the extra lines :-)
cheers
andrew