pgsql: Refactor output file handling when forking syslogger under EXEC_ - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Refactor output file handling when forking syslogger under EXEC_
Date
Msg-id E1mVOpg-0002Jf-2p@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Refactor output file handling when forking syslogger under EXEC_BACKEND

A forked logging collector in EXEC_BACKEND builds passes down file
descriptors (or HANDLEs in WIN32) through a command for files to be
reopened (for stderr and csvlog).  Some of its logic was duplicated, and
this commit refactors the code with some wrapper routines for file
reopening after forking and fd grabbing when building the command for
the fork.

While on it, this simplifies a use of "long" in the code, introduced by
ab0ba6e to take care of a warning related to MinGW-W64 when mapping a
intptr_t to a printed value.  "long" is 32-bit long on Windows, and
interoperability of Win32 and Win64 ensures that handles are always
32-bit significant, so we can just use "int" for the same result.  This
also makes the new routines more symmetric.

This change makes easier the introduction of new log destinations in the
logging collector, and this is not the only piece of refactoring
planned.  I have tested this change with EXEC_BACKEND on linux, macos,
and of course MSVC (both Win32 and Win64), but not MinGW so the
buildfarm may have something to say here.

Author: Sehrope Sarkuni, Michael Paquier
Discussion: https://postgr.es/m/CAH7T-aqswBM6JWe4pDehi1uOiufqe06DJWaU5=X7dDLyqUExHg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5b0b699f748ead1b7414c58aaa7cf0ea83808147

Modified Files
--------------
src/backend/postmaster/syslogger.c | 122 +++++++++++++++++++------------------
1 file changed, 62 insertions(+), 60 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix instability in contrib/bloom TAP tests.
Next
From: Michael Paquier
Date:
Subject: pgsql: doc: Fix some typos and markups