Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Only fall back to AF_INET searches when looking for AF_UNSPEC addresses

  • Loading branch information...
commit bb4096effef7f0001339669a4abf9448ec1f8743 1 parent 1b9c2a3
authored June 13, 2011

Showing 1 changed file with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. 13  ares_gethostbyname.c
13  ares_gethostbyname.c
@@ -194,11 +194,11 @@ static void host_callback(void *arg, int status, int timeouts,
194 194
       else if (hquery->sent_family == AF_INET6)
195 195
         {
196 196
           status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
197  
-          if (status == ARES_ENODATA || status == ARES_EBADRESP) {
  197
+          if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
  198
+               hquery->want_family == AF_UNSPEC) {
198 199
             /* The query returned something but either there were no AAAA
199 200
                records (e.g. just CNAME) or the response was malformed.  Try
200  
-               looking up A instead.  We should possibly limit this
201  
-               attempt-next logic to AF_UNSPEC lookups only. */
  201
+               looking up A instead. */
202 202
             hquery->sent_family = AF_INET;
203 203
             ares_search(hquery->channel, hquery->name, C_IN, T_A,
204 204
                         host_callback, hquery);
@@ -210,11 +210,10 @@ static void host_callback(void *arg, int status, int timeouts,
210 210
       end_hquery(hquery, status, host);
211 211
     }
212 212
   else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
213  
-            status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
  213
+            status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
  214
+            hquery->want_family == AF_UNSPEC))
214 215
     {
215  
-      /* The AAAA query yielded no useful result.  Now look up an A instead.
216  
-         We should possibly limit this attempt-next logic to AF_UNSPEC lookups
217  
-         only. */
  216
+      /* The AAAA query yielded no useful result.  Now look up an A instead. */
218 217
       hquery->sent_family = AF_INET;
219 218
       ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
220 219
                   hquery);

0 notes on commit bb4096e

Please sign in to comment.
Something went wrong with that request. Please try again.