]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #851: DNS retransmits too often
authorhno <>
Sat, 3 Apr 2004 21:52:21 +0000 (21:52 +0000)
committerhno <>
Sat, 3 Apr 2004 21:52:21 +0000 (21:52 +0000)
Correct the DNS retransmission timer to double per attempt.

src/dns_internal.cc
src/typedefs.h

index 20bf511861f9e65b5386de21f93dda7b5a914873..cce96f3829dbfaf7629859237f7be0bab1ce31ea 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.59 2003/04/24 06:35:09 hno Exp $
+ * $Id: dns_internal.cc,v 1.60 2004/04/03 14:52:21 hno Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -75,6 +75,8 @@ struct _idns_query
     IDNSCB *callback;
     void *callback_data;
     int attempt;
+    const char *error;
+    int rcode;
 };
 
 struct _ns
@@ -573,11 +575,15 @@ idnsGrokReply(const char *buf, size_t sz)
 
     dlinkDelete(&q->lru, &lru_list);
     idnsRcodeCount(n, q->attempt);
+    q->error = NULL;
 
     if (n < 0) {
         debug(78, 3) ("idnsGrokReply: error %d\n", rfc1035_errno);
 
-        if (-2 == n && ++q->attempt < MAX_ATTEMPT) {
+        q->error = rfc1035_error_message;
+        q->rcode = -n;
+
+        if (q->rcode == 2 && ++q->attempt < MAX_ATTEMPT) {
             /*
              * RCODE 2 is "Server failure - The name server was
              * unable to process this query due to a problem with
@@ -595,7 +601,7 @@ idnsGrokReply(const char *buf, size_t sz)
     q->callback = NULL;
 
     if (cbdataReferenceValidDone(q->callback_data, &cbdata))
-        callback(cbdata, answers, n);
+        q->callback(q->callback_data, answers, n, q->error);
 
     rfc1035RRDestroy(answers, n);
 
@@ -706,7 +712,7 @@ idnsCheckQueue(void *unused)
 
         q = (idns_query *)n->data;
 
-        if (tvSubDsec(q->sent_t, current_time) < Config.Timeout.idns_retransmit * (1 << q->nsends % nns))
+        if (tvSubDsec(q->sent_t, current_time) < Config.Timeout.idns_retransmit * (1 << (q->nsends - 1) % nns))
             break;
 
         debug(78, 3) ("idnsCheckQueue: ID %#04x timeout\n",
@@ -727,8 +733,12 @@ idnsCheckQueue(void *unused)
             callback = q->callback;
             q->callback = NULL;
 
-            if (cbdataReferenceValidDone(q->callback_data, &cbdata))
-                callback(cbdata, NULL, 0);
+            if (cbdataReferenceValidDone(q->callback_data, &cbdata)) {
+                if (q->rcode != 0)
+                    q->callback(q->callback_data, NULL, -q->rcode, q->error);
+                else
+                    q->callback(q->callback_data, NULL, -16, "Timeout");
+            }
 
             memFree(q, MEM_IDNS_QUERY);
         }
@@ -846,7 +856,7 @@ idnsALookup(const char *name, IDNSCB * callback, void *data)
 
     if (0 == q->id) {
         /* problem with query data -- query not sent */
-        callback(data, NULL, 0);
+        callback(data, NULL, 0, "Internal error");
         memFree(q, MEM_IDNS_QUERY);
         return;
     }
index 450b0f8f1686e0856e8f55830640e98b4f8e5277..22e702ed54b642c48d57416822d71a1cc6361a38 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.171 2003/10/16 21:40:16 robertc Exp $
+ * $Id: typedefs.h,v 1.172 2004/04/03 14:52:21 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -316,7 +316,7 @@ typedef stateful_helper_callback_t HLPSCB(void *, void *lastserver, char *buf);
 typedef int HLPSAVAIL(void *);
 typedef void HLPSONEQ(void *);
 typedef void HLPCMDOPTS(int *argc, char **argv);
-typedef void IDNSCB(void *, rfc1035_rr *, int);
+typedef void IDNSCB(void *, rfc1035_rr *, int, const char *);
 
 typedef double hbase_f(double);
 typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, int count);