use binary mode on syslog pipe on windows to avoid upsetting chunking protocol

Started by Andrew Dunstanalmost 19 years ago5 messagespatches
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

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
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#1)
Re: use binary mode on syslog pipe on windows to avoid upsetting chunking protocol

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

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#2)
Re: use binary mode on syslog pipe on windows to avoid upsetting chunking protocol

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
#4Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#3)
Re: use binary mode on syslog pipe on windows to avoid upsetting chunking protocol

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

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#4)
Re: use binary mode on syslog pipe on windows to avoid upsetting chunking protocol

Andrew Dunstan wrote:

This small patch makes the syslog pipe use binary mode on Windows

This is now committed and ported back to 8.0.

cheers

andrew