On Sat, 23 Apr 2016, Ray Satiro via curl-library wrote:

I think the reason it fails when 81 is because it's looking in the DNS cache for test.com port 81 and sees it doesn't exist whereas test.com port 80 exists.

The port number is a clue, yes. The problems seems like a regression introduced in 09b5a998 and happens because Curl_fetch_addr() is used to see if anyone else has resolved the name and it asks for... the host name and not the proxy name. And since the host name is already in the cache, it takes that and continues!

I'm attaching a simple little patch that fixes it for me. It also changes the "Hostname was found in DNS cache" logging a bit in a way that would've made it easier for us to spot this problem.

Thoughts? (silence is fine, and then I'll push this soonish)

--

 / daniel.haxx.se
From dfb9f95e2cca5bf208b10b2e9a63590d63759bc1 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <[email protected]>
Date: Sat, 23 Apr 2016 22:46:15 +0200
Subject: [PATCH] multi: accidentally used resolved host name instead of proxy

Regression introduced in 09b5a998

Bug: https://curl.haxx.se/mail/lib-2016-04/0084.html
Reported-by: BoBo
---
 lib/multi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/multi.c b/lib/multi.c
index aec377d..1184482 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1464,11 +1464,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
     {
       struct Curl_dns_entry *dns = NULL;
       struct connectdata *conn = data->easy_conn;
       const char *hostname;
 
-      if(conn->bits.conn_to_host)
+      if(conn->bits.proxy)
+        hostname = conn->proxy.name;
+      else if(conn->bits.conn_to_host)
         hostname = conn->conn_to_host.name;
       else
         hostname = conn->host.name;
 
       /* check if we have the name resolved by now */
@@ -1478,11 +1480,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
 #ifdef CURLRES_ASYNCH
         conn->async.dns = dns;
         conn->async.done = TRUE;
 #endif
         result = CURLE_OK;
-        infof(data, "Hostname was found in DNS cache\n");
+        infof(data, "Hostname '%s' was found in DNS cache\n", hostname);
       }
 
       if(!dns)
         result = Curl_resolver_is_resolved(data->easy_conn, &dns);
 
-- 
2.8.1

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Reply via email to