Skip to content

Commit 2b39831

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 8b3d528 commit 2b39831

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/backend/postmaster/postmaster.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -4113,6 +4113,14 @@ BackendInitialize(Port *port)
41134113
else
41144114
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s(%s)", remote_host, remote_port);
41154115

4116+
/*
4117+
* Save remote_host and remote_port in port structure (after this, they
4118+
* will appear in log_line_prefix data for log messages).
4119+
*/
4120+
port->remote_host = strdup(remote_host);
4121+
port->remote_port = strdup(remote_port);
4122+
4123+
/* And now we can issue the Log_connections message, if wanted */
41164124
if (Log_connections)
41174125
{
41184126
if (remote_port[0])
@@ -4126,12 +4134,6 @@ BackendInitialize(Port *port)
41264134
remote_host)));
41274135
}
41284136

4129-
/*
4130-
* save remote_host and remote_port in port structure
4131-
*/
4132-
port->remote_host = strdup(remote_host);
4133-
port->remote_port = strdup(remote_port);
4134-
41354137
/*
41364138
* If we did a reverse lookup to name, we might as well save the results
41374139
* rather than possibly repeating the lookup during authentication.

0 commit comments

Comments
 (0)