mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-28 19:21:48 +02:00
Properly print the IP number and "localhost" for failed localhost
connections when the server is down, on Win32.
This commit is contained in:
parent
4754dbf4c3
commit
7e95337d58
@ -1030,20 +1030,25 @@ connectFailureMessage(PGconn *conn, int errorno)
|
|||||||
else
|
else
|
||||||
strcpy(host_addr, "???");
|
strcpy(host_addr, "???");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user did not supply an IP address using 'hostaddr', and
|
||||||
|
* 'host' was missing or does not match our lookup, display the
|
||||||
|
* looked-up IP address.
|
||||||
|
*/
|
||||||
display_host_addr = (conn->pghostaddr == NULL) &&
|
display_host_addr = (conn->pghostaddr == NULL) &&
|
||||||
(conn->pghost != NULL) &&
|
((conn->pghost == NULL) ||
|
||||||
(strcmp(conn->pghost, host_addr) != 0);
|
(strcmp(conn->pghost, host_addr) != 0));
|
||||||
|
|
||||||
appendPQExpBuffer(&conn->errorMessage,
|
appendPQExpBuffer(&conn->errorMessage,
|
||||||
libpq_gettext("could not connect to server: %s\n"
|
libpq_gettext("could not connect to server: %s\n"
|
||||||
"\tIs the server running on host \"%s\"%s%s%s and accepting\n"
|
"\tIs the server running on host \"%s\"%s%s%s and accepting\n"
|
||||||
"\tTCP/IP connections on port %s?\n"),
|
"\tTCP/IP connections on port %s?\n"),
|
||||||
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
|
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
|
||||||
conn->pghostaddr
|
(conn->pghostaddr && conn->pghostaddr[0] != '\0')
|
||||||
? conn->pghostaddr
|
? conn->pghostaddr
|
||||||
: (conn->pghost
|
: (conn->pghost && conn->pghost[0] != '\0')
|
||||||
? conn->pghost
|
? conn->pghost
|
||||||
: "???"),
|
: DefaultHost,
|
||||||
/* display the IP address only if not already output */
|
/* display the IP address only if not already output */
|
||||||
display_host_addr ? " (" : "",
|
display_host_addr ? " (" : "",
|
||||||
display_host_addr ? host_addr : "",
|
display_host_addr ? host_addr : "",
|
||||||
@ -1304,7 +1309,7 @@ connectDBStart(PGconn *conn)
|
|||||||
UNIXSOCK_PATH(portstr, portnum, conn->pgunixsocket);
|
UNIXSOCK_PATH(portstr, portnum, conn->pgunixsocket);
|
||||||
#else
|
#else
|
||||||
/* Without Unix sockets, default to localhost instead */
|
/* Without Unix sockets, default to localhost instead */
|
||||||
node = "localhost";
|
node = DefaultHost;
|
||||||
hint.ai_family = AF_UNSPEC;
|
hint.ai_family = AF_UNSPEC;
|
||||||
#endif /* HAVE_UNIX_SOCKETS */
|
#endif /* HAVE_UNIX_SOCKETS */
|
||||||
}
|
}
|
||||||
@ -3388,7 +3393,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
|||||||
/* hostname */
|
/* hostname */
|
||||||
hostname = url + strlen(LDAP_URL);
|
hostname = url + strlen(LDAP_URL);
|
||||||
if (*hostname == '/') /* no hostname? */
|
if (*hostname == '/') /* no hostname? */
|
||||||
hostname = "localhost"; /* the default */
|
hostname = DefaultHost; /* the default */
|
||||||
|
|
||||||
/* dn, "distinguished name" */
|
/* dn, "distinguished name" */
|
||||||
p = strchr(url + strlen(LDAP_URL), '/');
|
p = strchr(url + strlen(LDAP_URL), '/');
|
||||||
|
Loading…
Reference in New Issue
Block a user