[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#540912: polipo: DNS timeouts on CNAMEs



severity 540912 important
tags 540912 patch
thanks

When polipo receives DNS answer telling that AAAA record does not
exist before receiving answer for A record with CNAMEs, it results in
timeout:

Host bits.wikimedia.org has both AAAA and CNAME -- ignoring CNAME.
Host bits.wikimedia.org has both AAAA and CNAME -- ignoring CNAME.
Host bits.wikimedia.org has both AAAA and CNAME -- ignoring CNAME.
Host bits.wikimedia.org has both AAAA and CNAME -- ignoring CNAME.
Host bits.wikimedia.org lookup failed: Timeout (131072).

Wikipedia is recently almost unusable with polipo, as the A record for
bits.wikimedia.org usually times out from local DNS cache about the
same time polipo reports its timeout while negative answer for AAAA is
still here.

The following patch fixes it for me:

--- polipo-1.0.4/dns.c.orig	2008-01-08 16:56:45.000000000 +0400
+++ polipo-1.0.4/dns.c	2010-03-29 18:28:43.225601510 +0500
@@ -1181,7 +1181,8 @@
         } else
             releaseAtom(value);
     } else if(af == 0) {
-        if(query->inet4 || query->inet6) {
+        if(query->inet4 && query->inet4->length ||
+	   query->inet6 && query->inet6->length) {
             do_log(L_WARN, "Host %s has both %s and CNAME -- "
                    "ignoring CNAME.\n", query->name->string,
                    query->inet4 ? "A" : "AAAA");
@@ -1207,7 +1208,8 @@
     if(object->flags & OBJECT_INITIAL) {
         assert(!object->headers);
         if(cname) {
-            assert(query->inet4 == NULL && query->inet6 == NULL);
+            assert(!(query->inet4 && query->inet4->length));
+            assert(!(query->inet6 && query->inet6->length));
             object->headers = cname;
             object->expires = current_time.tv_sec + ttl;
         } else if((!query->inet4 || query->inet4->length == 0) &&



Reply to: