mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	Initialize ListenSocket array earlier.
After commitb0bea38705, 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 commit9a86f03b4ein version 13, which moved the SysLogger_Start() call to before initializing ListenSockets. We just didn't notice until commitb0bea38705added 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
This commit is contained in:
		| @@ -1096,6 +1096,17 @@ PostmasterMain(int argc, char *argv[]) | ||||
| 				 errmsg("could not remove file \"%s\": %m", | ||||
| 						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 | ||||
| 	 */ | ||||
| @@ -1130,15 +1141,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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user