use binary mode on syslog pipe on windows to avoid upsetting chunking protocol
От | Andrew Dunstan |
---|---|
Тема | use binary mode on syslog pipe on windows to avoid upsetting chunking protocol |
Дата | |
Msg-id | 46ADDC82.1090502@dunslane.net обсуждение исходный текст |
Ответы |
Re: use binary mode on syslog pipe on windows to avoid upsetting chunking protocol
(Tom Lane <tgl@sss.pgh.pa.us>)
|
Список | pgsql-patches |
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 Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v retrieving revision 1.535 diff -c -r1.535 postmaster.c *** src/backend/postmaster/postmaster.c 24 Jul 2007 04:54:09 -0000 1.535 --- src/backend/postmaster/postmaster.c 30 Jul 2007 12:30:28 -0000 *************** *** 3385,3390 **** --- 3385,3394 ---- MyProcPid = getpid(); /* reset MyProcPid */ + #ifdef WIN32 + _setmode(fileno(stderr),_O_BINARY); + #endif + /* Lose the postmaster's on-exit routines (really a no-op) */ on_exit_reset(); Index: src/backend/postmaster/syslogger.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/syslogger.c,v retrieving revision 1.33 diff -c -r1.33 syslogger.c *** src/backend/postmaster/syslogger.c 19 Jul 2007 19:13:43 -0000 1.33 --- src/backend/postmaster/syslogger.c 30 Jul 2007 12:30:28 -0000 *************** *** 162,167 **** --- 162,171 ---- MyProcPid = getpid(); /* reset MyProcPid */ + #ifdef WIN32 + _setmode(_fileno(stderr),_O_TEXT); + #endif + #ifdef EXEC_BACKEND syslogger_parseArgs(argc, argv); #endif /* EXEC_BACKEND */ *************** *** 533,544 **** fflush(stderr); fd = _open_osfhandle((long) syslogPipe[1], ! _O_APPEND | _O_TEXT); if (dup2(fd, _fileno(stderr)) < 0) ereport(FATAL, (errcode_for_file_access(), errmsg("could not redirect stderr: %m"))); close(fd); /* Now we are done with the write end of the pipe. */ CloseHandle(syslogPipe[1]); syslogPipe[1] = 0; --- 537,549 ---- fflush(stderr); fd = _open_osfhandle((long) syslogPipe[1], ! _O_APPEND | _O_BINARY); if (dup2(fd, _fileno(stderr)) < 0) ereport(FATAL, (errcode_for_file_access(), errmsg("could not redirect stderr: %m"))); close(fd); + _setmode(_fileno(stderr),_O_BINARY); /* Now we are done with the write end of the pipe. */ CloseHandle(syslogPipe[1]); syslogPipe[1] = 0; *************** *** 626,632 **** fd = atoi(*argv++); if (fd != 0) { ! fd = _open_osfhandle(fd, _O_APPEND); if (fd > 0) { syslogFile = fdopen(fd, "a"); --- 631,637 ---- fd = atoi(*argv++); if (fd != 0) { ! fd = _open_osfhandle(fd, _O_APPEND | _O_TEXT); if (fd > 0) { syslogFile = fdopen(fd, "a"); *************** *** 990,995 **** --- 995,1001 ---- /* 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);
В списке pgsql-patches по дате отправления:
Следующее
От: Gregory StarkДата:
Сообщение: Export user visible function to make use of convert_to_scalar