aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-02-16 13:14:55 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-02-16 13:14:55 +0000
commit39926181ea02fa391c7c4b7c27a13de199ca8170 (patch)
treecc0882522763f330356b49bcaa8ac9ef50e2fcc8 /lib
parent8415b4a2714b9092c9bb6b2622a2fab60e6cc594 (diff)
Fix verbosconnect() when ipv6-enabled to not assume that conn->serv_addr
is a valid pointer, but instead always depend on the passed-in dns pointer. This happens to be NULL when the connection is re-used...
Diffstat (limited to 'lib')
-rw-r--r--lib/url.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/lib/url.c b/lib/url.c
index 188263b61..aa15ec009 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1849,26 +1849,36 @@ static void verboseconnect(struct connectdata *conn,
/* Figure out the ip-number and display the first host name it shows: */
#ifdef ENABLE_IPV6
- (void)dns; /* not used in the IPv6 enabled version */
{
char hbuf[NI_MAXHOST];
#ifdef NI_WITHSCOPEID
- const int niflags = NI_NUMERICHOST | NI_WITHSCOPEID;
+#define NIFLAGS NI_NUMERICHOST | NI_WITHSCOPEID
#else
- const int niflags = NI_NUMERICHOST;
+#define NIFLAGS NI_NUMERICHOST
#endif
- struct addrinfo *ai = conn->serv_addr;
-
- if (getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf), NULL, 0,
- niflags)) {
- snprintf(hbuf, sizeof(hbuf), "?");
+ if(dns) {
+ struct addrinfo *ai = dns->addr;
+
+ /* Lookup the name of the given address. This should probably be remade
+ to use the DNS cache instead, as the host name is most likely cached
+ already. */
+ if (getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf), NULL, 0,
+ NIFLAGS)) {
+ snprintf(hbuf, sizeof(hbuf), "unknown");
+ }
+ else {
+ if (ai->ai_canonname) {
+ infof(data, "Connected to %s (%s) port %d\n", ai->ai_canonname, hbuf,
+ conn->port);
+ return;
+ }
+ }
}
- if (ai->ai_canonname) {
- infof(data, "Connected to %s (%s) port %d\n", ai->ai_canonname, hbuf,
- conn->port);
- } else {
- infof(data, "Connected to %s port %d\n", hbuf, conn->port);
+ else {
+ snprintf(hbuf, sizeof(hbuf), "same host");
}
+
+ infof(data, "Connected to %s port %d\n", hbuf, conn->port);
}
#else
{