diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2023-08-29 09:09:40 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2023-08-29 09:09:40 +0300 |
commit | 5fec3c870ec8c1e9c88c368243b1533a2d5c53e7 (patch) | |
tree | c030e744bd86da6cb0c1254689d2b28ca7108b01 | |
parent | f593c5517d14a949ae659eec470eb6bc0d2fdd5d (diff) | |
download | postgresql-5fec3c870ec8c1e9c88c368243b1533a2d5c53e7.tar.gz postgresql-5fec3c870ec8c1e9c88c368243b1533a2d5c53e7.zip |
Initialize ListenSocket array earlier.
After commit b0bea38705, syslogger prints 63 warnings about failing to
close a listen socket at postmaster startup. That's because the
syslogger process forks before the ListenSockets array is initialized,
so ClosePostmasterPorts() calls "close(0)" 64 times. The first call
succeeds, because fd 0 is stdin.
This has been like this since commit 9a86f03b4e in version 13, which
moved the SysLogger_Start() call to before initializing ListenSockets.
We just didn't notice until commit b0bea38705 added the LOG message.
Reported by Michael Paquier and Jeff Janes.
Author: Michael Paquier
Discussion: https://www.postgresql.org/message-id/ZOvvuQe0rdj2slA9%40paquier.xyz
Discussion: https://www.postgresql.org/message-id/ZO0fgDwVw2SUJiZx@paquier.xyz#482670177eb4eaf4c9f03c1eed963e5f
Backpatch-through: 13
-rw-r--r-- | src/backend/postmaster/postmaster.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 41bccb46a87..d7bfb28ff35 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -1142,6 +1142,17 @@ PostmasterMain(int argc, char *argv[]) LOG_METAINFO_DATAFILE))); /* + * Initialize input sockets. + * + * Mark them all closed, and set up an on_proc_exit function that's + * charged with closing the sockets again at postmaster shutdown. + */ + for (i = 0; i < MAXLISTEN; i++) + ListenSocket[i] = PGINVALID_SOCKET; + + on_proc_exit(CloseServerPorts, 0); + + /* * If enabled, start up syslogger collection subprocess */ SysLoggerPID = SysLogger_Start(); @@ -1175,15 +1186,7 @@ PostmasterMain(int argc, char *argv[]) /* * Establish input sockets. - * - * First, mark them all closed, and set up an on_proc_exit function that's - * charged with closing the sockets again at postmaster shutdown. */ - for (i = 0; i < MAXLISTEN; i++) - ListenSocket[i] = PGINVALID_SOCKET; - - on_proc_exit(CloseServerPorts, 0); - if (ListenAddresses) { char *rawstring; |