diff options
author | Peter Eisentraut | 2012-10-05 01:45:14 +0000 |
---|---|---|
committer | Peter Eisentraut | 2012-10-05 01:45:14 +0000 |
commit | c424d0d1052cb4053c8712ac44123f9b9a9aa3f2 (patch) | |
tree | ff1dfd01f241fdb62a9d8892acd47ab38a931bfc | |
parent | e1e60694b4a69786dc5ff27e340afeaad7833eb9 (diff) |
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.
-rw-r--r-- | src/backend/postmaster/postmaster.c | 19 | ||||
-rw-r--r-- | src/port/getaddrinfo.c | 5 |
2 files changed, 6 insertions, 18 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index dff4c71096..e73caa8b29 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -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 diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c index c117012ec7..749c35fc0c 100644 --- a/src/port/getaddrinfo.c +++ b/src/port/getaddrinfo.c @@ -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; |