Initialize ListenSocket array earlier.
authorHeikki Linnakangas <[email protected]>
Tue, 29 Aug 2023 06:09:40 +0000 (09:09 +0300)
committerHeikki Linnakangas <[email protected]>
Tue, 29 Aug 2023 06:12:35 +0000 (09:12 +0300)
commit0c10240600ad3d7a139737467184777ea822f593
tree4bbd0d58db37fd9314155b34d8a34caa6aff5e20
parent8700851352a89e9e78da9df31fd6d3a75df98470
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/[email protected]#482670177eb4eaf4c9f03c1eed963e5f
Backpatch-through: 13
src/backend/postmaster/postmaster.c