Skip to content

Commit 5f38ff3

Browse files
committed
Initialize ListenSocket array earlier.
After commit b0bea38, 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 9a86f03 in version 13, which moved the SysLogger_Start() call to before initializing ListenSockets. We just didn't notice until commit b0bea38 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
1 parent d94dadc commit 5f38ff3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,17 @@ PostmasterMain(int argc, char *argv[])
11431143
errmsg("could not remove file \"%s\": %m",
11441144
LOG_METAINFO_DATAFILE)));
11451145

1146+
/*
1147+
* Initialize input sockets.
1148+
*
1149+
* Mark them all closed, and set up an on_proc_exit function that's
1150+
* charged with closing the sockets again at postmaster shutdown.
1151+
*/
1152+
for (i = 0; i < MAXLISTEN; i++)
1153+
ListenSocket[i] = PGINVALID_SOCKET;
1154+
1155+
on_proc_exit(CloseServerPorts, 0);
1156+
11461157
/*
11471158
* If enabled, start up syslogger collection subprocess
11481159
*/
@@ -1177,15 +1188,7 @@ PostmasterMain(int argc, char *argv[])
11771188

11781189
/*
11791190
* Establish input sockets.
1180-
*
1181-
* First, mark them all closed, and set up an on_proc_exit function that's
1182-
* charged with closing the sockets again at postmaster shutdown.
11831191
*/
1184-
for (i = 0; i < MAXLISTEN; i++)
1185-
ListenSocket[i] = PGINVALID_SOCKET;
1186-
1187-
on_proc_exit(CloseServerPorts, 0);
1188-
11891192
if (ListenAddresses)
11901193
{
11911194
char *rawstring;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy