]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
developer: marka
authorMark Andrews <marka@isc.org>
Fri, 23 Aug 2002 00:27:10 +0000 (00:27 +0000)
committerMark Andrews <marka@isc.org>
Fri, 23 Aug 2002 00:27:10 +0000 (00:27 +0000)
reviewed: jinmei
1364.  [func]          Use response times to select forwarders.

CHANGES
lib/dns/resolver.c

diff --git a/CHANGES b/CHANGES
index 5af6e90f30f094097418d50f0924111a7266b2e8..289aa6a1ed6ee3021655811b1591f4ca71090346 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+1364.  [func]          Use response times to select forwarders.
+
 1363.  [contrib]       queryperf usage was incomplete.  Add '-h' for help.
 
 1362.  [func]          "localhost" and "localnet" acls now include IPv6
index 0588b73002a93b4e0a45e17d41302cac5406338b..46eacefef987b7fd7c0770aa59cda8baaee61734 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resolver.c,v 1.246 2002/08/09 06:12:50 marka Exp $ */
+/* $Id: resolver.c,v 1.247 2002/08/23 00:27:10 marka Exp $ */
 
 #include <config.h>
 
@@ -210,6 +210,7 @@ struct fetchctx {
 #define FCTX_ATTR_WANTCACHE            0x10
 #define FCTX_ATTR_WANTNCACHE           0x20
 #define FCTX_ATTR_NEEDEDNS0            0x40
+#define FCTX_ATTR_TRIEDFIND            0x80
 
 #define HAVE_ANSWER(f)         (((f)->attributes & FCTX_ATTR_HAVEANSWER) != \
                                 0)
@@ -222,6 +223,7 @@ struct fetchctx {
 #define WANTCACHE(f)           (((f)->attributes & FCTX_ATTR_WANTCACHE) != 0)
 #define WANTNCACHE(f)          (((f)->attributes & FCTX_ATTR_WANTNCACHE) != 0)
 #define NEEDEDNS0(f)           (((f)->attributes & FCTX_ATTR_NEEDEDNS0) != 0)
+#define TRIEDFIND(f)           (((f)->attributes & FCTX_ATTR_TRIEDFIND) != 0)
 
 struct dns_fetch {
        unsigned int                    magic;
@@ -371,6 +373,8 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
        resquery_t *query;
        unsigned int rtt;
        unsigned int factor;
+       dns_adbfind_t *find;
+       dns_adbaddrinfo_t *addrinfo;
 
        query = *queryp;
        fctx = query->fctx;
@@ -415,11 +419,15 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
        /*
         * Age RTTs of servers not tried.
         */
-       if (finish != NULL) {
-               dns_adbfind_t *find;
-               dns_adbaddrinfo_t *addrinfo;
-
-               factor = DNS_ADB_RTTADJAGE;
+       factor = DNS_ADB_RTTADJAGE;
+       if (finish != NULL)
+               for (addrinfo = ISC_LIST_HEAD(fctx->forwaddrs);
+                    addrinfo != NULL;
+                    addrinfo = ISC_LIST_NEXT(addrinfo, publink))
+                       if (UNMARKED(addrinfo))
+                               dns_adb_adjustsrtt(fctx->adb, addrinfo,
+                                                  0, factor);
+       if (finish != NULL && !TRIEDFIND(fctx))
                 for (find = ISC_LIST_HEAD(fctx->finds);
                     find != NULL;
                     find = ISC_LIST_NEXT(find, publink))
@@ -429,7 +437,6 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
                                if (UNMARKED(addrinfo))
                                        dns_adb_adjustsrtt(fctx->adb, addrinfo,
                                                           0, factor);
-       }
 
        if (query->dispentry != NULL)
                dns_dispatch_removeresponse(&query->dispentry, deventp);
@@ -1481,8 +1488,16 @@ fctx_getaddresses(fetchctx_t *fctx) {
                result = dns_adb_findaddrinfo(fctx->adb,
                                              sa, &ai, 0);  /* XXXMLG */
                if (result == ISC_R_SUCCESS) {
+                       dns_adbaddrinfo_t *cur;
                        ai->flags |= FCTX_ADDRINFO_FORWARDER;
-                       ISC_LIST_APPEND(fctx->forwaddrs, ai, publink);
+                       cur = ISC_LIST_HEAD(fctx->forwaddrs);
+                       while (cur != NULL && cur->srtt < ai->srtt)
+                               cur = ISC_LIST_NEXT(cur, publink);
+                       if (cur != NULL)
+                               ISC_LIST_INSERTBEFORE(fctx->forwaddrs, cur,
+                                                     ai, publink);
+                       else
+                               ISC_LIST_APPEND(fctx->forwaddrs, ai, publink);
                }
                sa = ISC_LIST_NEXT(sa, link);
        }
@@ -1656,11 +1671,6 @@ fctx_getaddresses(fetchctx_t *fctx) {
                 * We've found some addresses.  We might still be looking
                 * for more addresses.
                 */
-               /*
-                * XXXRTH  We could sort the forwaddrs here if the caller
-                *         wants to use the forwaddrs in "best order" as
-                *         opposed to "fixed order".
-                */
                sort_finds(fctx);
                result = ISC_R_SUCCESS;
        }
@@ -1752,6 +1762,8 @@ fctx_nextaddress(fetchctx_t *fctx) {
                }
        }
 
+       fctx->attributes |= FCTX_ATTR_TRIEDFIND;
+
        /*
         * No forwarders.  Move to the next find.
         */