Skip to content

Commit 9bbfca8

Browse files
committed
Fix startup so that log prefix %h works for the log_connections message.
We entirely randomly chose to initialize port->remote_host just after printing the log_connections message, when we could perfectly well do it just before, allowing %h and %r to work for that message. Per gripe from Artem Tomyuk.
1 parent 7a47262 commit 9bbfca8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4005,6 +4005,14 @@ BackendInitialize(Port *port)
40054005
else
40064006
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s(%s)", remote_host, remote_port);
40074007

4008+
/*
4009+
* Save remote_host and remote_port in port structure (after this, they
4010+
* will appear in log_line_prefix data for log messages).
4011+
*/
4012+
port->remote_host = strdup(remote_host);
4013+
port->remote_port = strdup(remote_port);
4014+
4015+
/* And now we can issue the Log_connections message, if wanted */
40084016
if (Log_connections)
40094017
{
40104018
if (remote_port[0])
@@ -4018,12 +4026,6 @@ BackendInitialize(Port *port)
40184026
remote_host)));
40194027
}
40204028

4021-
/*
4022-
* save remote_host and remote_port in port structure
4023-
*/
4024-
port->remote_host = strdup(remote_host);
4025-
port->remote_port = strdup(remote_port);
4026-
40274029
/*
40284030
* If we did a reverse lookup to name, we might as well save the results
40294031
* rather than possibly repeating the lookup during authentication.

0 commit comments

Comments
 (0)