Skip to content

Commit b8682a7

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 cc988fb commit b8682a7

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
@@ -4068,6 +4068,14 @@ BackendInitialize(Port *port)
40684068
else
40694069
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s(%s)", remote_host, remote_port);
40704070

4071+
/*
4072+
* Save remote_host and remote_port in port structure (after this, they
4073+
* will appear in log_line_prefix data for log messages).
4074+
*/
4075+
port->remote_host = strdup(remote_host);
4076+
port->remote_port = strdup(remote_port);
4077+
4078+
/* And now we can issue the Log_connections message, if wanted */
40714079
if (Log_connections)
40724080
{
40734081
if (remote_port[0])
@@ -4081,12 +4089,6 @@ BackendInitialize(Port *port)
40814089
remote_host)));
40824090
}
40834091

4084-
/*
4085-
* save remote_host and remote_port in port structure
4086-
*/
4087-
port->remote_host = strdup(remote_host);
4088-
port->remote_port = strdup(remote_port);
4089-
40904092
/*
40914093
* If we did a reverse lookup to name, we might as well save the results
40924094
* rather than possibly repeating the lookup during authentication.

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