static void compound_results(struct ResolverResults *res,
Curl_addrinfo *ai)
{
- Curl_addrinfo *ai_tail;
if(!ai)
return;
- ai_tail = ai;
+ /* Add the new results to the list of old results. */
+#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
+ if(res->temp_ai && res->temp_ai->ai_family == PF_INET) {
+ /* We have some results already and we need
+ * to make sure that IPv4 entries always
+ * go to the head of the list to try to
+ * connect with IPV4 family first */
+ struct Curl_addrinfo *temp_ai_tail = res->temp_ai;
- while(ai_tail->ai_next)
- ai_tail = ai_tail->ai_next;
+ while(temp_ai_tail->ai_next)
+ temp_ai_tail = temp_ai_tail->ai_next;
- /* Add the new results to the list of old results. */
- ai_tail->ai_next = res->temp_ai;
- res->temp_ai = ai;
+ temp_ai_tail->ai_next = ai;
+ }
+ else
+#endif /* CURLRES_IPV6 */
+ {
+ struct Curl_addrinfo *ai_tail = ai;
+ ai_tail = ai;
+
+ while(ai_tail->ai_next)
+ ai_tail = ai_tail->ai_next;
+
+ /* Add the new results to the list of old results. */
+ ai_tail->ai_next = res->temp_ai;
+ res->temp_ai = ai;
+ }
}
/*