]> granicus.if.org Git - postgresql/commitdiff
Remove redundant code for getnameinfo() replacement
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 5 Oct 2012 01:45:14 +0000 (21:45 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 5 Oct 2012 01:45:14 +0000 (21:45 -0400)
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.

src/backend/postmaster/postmaster.c
src/port/getaddrinfo.c

index dff4c710967323fdaddc8070e8f8f01c4e3d998d..e73caa8b294317ce23885909dd276b7267c901dd 100644 (file)
@@ -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
index c117012ec7eadf8ea87c254a55c08a4372e3d9a2..749c35fc0c7bf0258ee87c9253c848fa796b8157 100644 (file)
@@ -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;