c260e0
From 74d01a8e4d48eedc526cffaf6a6bc782b139e068 Mon Sep 17 00:00:00 2001
c260e0
From: Kim Vandry <vandry@users.sf.net>
c260e0
Date: Mon, 18 Feb 2013 21:36:34 +0100
c260e0
Subject: [PATCH 1/2] Curl_resolver_is_resolved: show proper host name on failed resolve
c260e0
c260e0
[upstream commit 25e577b33d00afb6630cf2cac98d6baa319e9aef]
c260e0
c260e0
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
c260e0
---
c260e0
 lib/asyn-thread.c |   35 ++++++++++++++++++++---------------
c260e0
 1 files changed, 20 insertions(+), 15 deletions(-)
c260e0
c260e0
diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c
c260e0
index 7a8294d..c392b21 100644
c260e0
--- a/lib/asyn-thread.c
c260e0
+++ b/lib/asyn-thread.c
c260e0
@@ -430,8 +430,19 @@ static const char *gai_strerror(int ecode)
c260e0
  * error
c260e0
  */
c260e0
 
c260e0
-static void resolver_error(struct connectdata *conn, const char *host_or_proxy)
c260e0
+static CURLcode resolver_error(struct connectdata *conn)
c260e0
 {
c260e0
+  const char *host_or_proxy;
c260e0
+  CURLcode rc;
c260e0
+  if(conn->bits.httpproxy) {
c260e0
+    host_or_proxy = "proxy";
c260e0
+    rc = CURLE_COULDNT_RESOLVE_PROXY;
c260e0
+  }
c260e0
+  else {
c260e0
+    host_or_proxy = "host";
c260e0
+    rc = CURLE_COULDNT_RESOLVE_HOST;
c260e0
+  }
c260e0
+
c260e0
   failf(conn->data, "Could not resolve %s: %s; %s", host_or_proxy,
c260e0
         conn->async.hostname,
c260e0
 #ifdef HAVE_GAI_STRERROR
c260e0
@@ -442,6 +453,7 @@ static void resolver_error(struct connectdata *conn, const char *host_or_proxy)
c260e0
         Curl_strerror(conn, conn->async.status)
c260e0
 #endif
c260e0
     );
c260e0
+  return rc;
c260e0
 }
c260e0
 
c260e0
 /*
c260e0
@@ -473,17 +485,9 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
c260e0
   if(entry)
c260e0
     *entry = conn->async.dns;
c260e0
 
c260e0
-  if(!conn->async.dns) {
c260e0
-    /* a name was not resolved */
c260e0
-    if(conn->bits.httpproxy) {
c260e0
-      resolver_error(conn, "proxy");
c260e0
-      rc = CURLE_COULDNT_RESOLVE_PROXY;
c260e0
-    }
c260e0
-    else {
c260e0
-      resolver_error(conn, "host");
c260e0
-      rc = CURLE_COULDNT_RESOLVE_HOST;
c260e0
-    }
c260e0
-  }
c260e0
+  if(!conn->async.dns)
c260e0
+    /* a name was not resolved, report error */
c260e0
+    rc = resolver_error(conn);
c260e0
 
c260e0
   destroy_async_data(&conn->async);
c260e0
 
c260e0
@@ -518,12 +522,13 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
c260e0
 
c260e0
   if(done) {
c260e0
     getaddrinfo_complete(conn);
c260e0
-    destroy_async_data(&conn->async);
c260e0
 
c260e0
     if(!conn->async.dns) {
c260e0
-      resolver_error(conn, "host");
c260e0
-      return CURLE_COULDNT_RESOLVE_HOST;
c260e0
+      CURLcode rc = resolver_error(conn);
c260e0
+      destroy_async_data(&conn->async);
c260e0
+      return rc;
c260e0
     }
c260e0
+    destroy_async_data(&conn->async);
c260e0
     *entry = conn->async.dns;
c260e0
   }
c260e0
   else {
c260e0
-- 
c260e0
1.7.1
c260e0