Remove redundant code for getnameinfo() replacement
Our getnameinfo() replacement implementation in getaddrinfo.c failed unless NI_NUMERICHOST and NI_NUMERICSERV were given as flags, because it doesn't resolve host names, only numeric IPs. But per standard, when those flags are not given, an implementation can still degrade to not returning host names, so this restriction is unnecessary. When we remove it, we can eliminate some code in postmaster.c that apparently tried to work around that.
This commit is contained in:
parent
e1e60694b4
commit
c424d0d105
@ -3437,6 +3437,7 @@ static void
|
||||
BackendInitialize(Port *port)
|
||||
{
|
||||
int status;
|
||||
int ret;
|
||||
char remote_host[NI_MAXHOST];
|
||||
char remote_port[NI_MAXSERV];
|
||||
char remote_ps_data[NI_MAXHOST];
|
||||
@ -3498,21 +3499,13 @@ BackendInitialize(Port *port)
|
||||
*/
|
||||
remote_host[0] = '\0';
|
||||
remote_port[0] = '\0';
|
||||
if (pg_getnameinfo_all(&port->raddr.addr, port->raddr.salen,
|
||||
if ((ret = pg_getnameinfo_all(&port->raddr.addr, port->raddr.salen,
|
||||
remote_host, sizeof(remote_host),
|
||||
remote_port, sizeof(remote_port),
|
||||
(log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV) != 0)
|
||||
{
|
||||
int ret = pg_getnameinfo_all(&port->raddr.addr, port->raddr.salen,
|
||||
remote_host, sizeof(remote_host),
|
||||
remote_port, sizeof(remote_port),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
|
||||
if (ret != 0)
|
||||
ereport(WARNING,
|
||||
(errmsg_internal("pg_getnameinfo_all() failed: %s",
|
||||
gai_strerror(ret))));
|
||||
}
|
||||
(log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV)) != 0)
|
||||
ereport(WARNING,
|
||||
(errmsg_internal("pg_getnameinfo_all() failed: %s",
|
||||
gai_strerror(ret))));
|
||||
if (remote_port[0] == '\0')
|
||||
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s", remote_host);
|
||||
else
|
||||
|
@ -373,11 +373,6 @@ getnameinfo(const struct sockaddr * sa, int salen,
|
||||
if (sa == NULL || (node == NULL && service == NULL))
|
||||
return EAI_FAIL;
|
||||
|
||||
/* We don't support those. */
|
||||
if ((node && !(flags & NI_NUMERICHOST))
|
||||
|| (service && !(flags & NI_NUMERICSERV)))
|
||||
return EAI_FAIL;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (sa->sa_family == AF_INET6)
|
||||
return EAI_FAMILY;
|
||||
|
Loading…
x
Reference in New Issue
Block a user