summaryrefslogtreecommitdiff
path: root/src/backend/postmaster/postmaster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-01-26 15:38:33 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-01-26 15:38:33 -0500
commit3a7af9d73b8f48d49837633ae07cf8c15b48ddd9 (patch)
tree61b79ac2e17f076d7fc1deb318e320170339497a /src/backend/postmaster/postmaster.c
parent49d65e857cad7ddc4d82f8276cc63ddce0be4ee1 (diff)
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.
Diffstat (limited to 'src/backend/postmaster/postmaster.c')
-rw-r--r--src/backend/postmaster/postmaster.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 2b16e3e26b2..504d98e2b35 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -3606,6 +3606,14 @@ BackendInitialize(Port *port)
else
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s(%s)", remote_host, remote_port);
+ /*
+ * Save remote_host and remote_port in port structure (after this, they
+ * will appear in log_line_prefix data for log messages).
+ */
+ port->remote_host = strdup(remote_host);
+ port->remote_port = strdup(remote_port);
+
+ /* And now we can issue the Log_connections message, if wanted */
if (Log_connections)
{
if (remote_port[0])
@@ -3620,12 +3628,6 @@ BackendInitialize(Port *port)
}
/*
- * save remote_host and remote_port in port structure
- */
- port->remote_host = strdup(remote_host);
- port->remote_port = strdup(remote_port);
-
- /*
* If we did a reverse lookup to name, we might as well save the results
* rather than possibly repeating the lookup during authentication.
*