Commit 42fe4941 authored by Michael Graff's avatar Michael Graff
Browse files

Minor API change. The 'factor' now ranges from 0..10. See adb.h for details.

parent 5012c7b9
......@@ -3401,14 +3401,14 @@ dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
REQUIRE(DNS_ADB_VALID(adb));
REQUIRE(DNS_ADBADDRINFO_VALID(addr));
if (factor == 0)
factor = 4;
REQUIRE(factor <= 10);
bucket = addr->entry->lock_bucket;
LOCK(&adb->entrylocks[bucket]);
new_srtt = (addr->entry->srtt * (factor - 1) + rtt) / factor;
new_srtt = (addr->entry->srtt / 10 * factor)
+ (rtt / 10 * (10 - factor));
addr->entry->srtt = new_srtt;
addr->srtt = new_srtt;
......
......@@ -445,6 +445,12 @@ dns_adb_adjustgoodness(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
* goodness value. This may include changes made by others.
*/
/*
* A reasonable default for RTT adjustments
*/
#define DNS_ADB_RTTADJDEFAULT 7 /* default scale */
#define DNS_ADB_RTTADJREPLACE 0 /* replace with our rtt */
void
dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
unsigned int rtt, unsigned int factor);
......@@ -453,7 +459,7 @@ dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
* (where srtt is the existing rtt value, and rtt and factor are arguments to
* this function):
*
* new_srtt = (srtt * (factor - 1) + rtt) / factor
* new_srtt = (old_srtt / 10 * factor) + (rtt / 10 * (10 - factor));
*
* Requires:
*
......@@ -461,9 +467,9 @@ dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
*
* addr be valid.
*
* Note:
* 0 <= factor <= 10
*
* If factor is zero, 4 will be used.
* Note:
*
* The srtt in addr will be updated to reflect the new global
* srtt value. This may include changes made by others.
......
......@@ -269,7 +269,7 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
if (finish != NULL) {
rtt = (unsigned int)isc_time_microdiff(finish, &query->start);
factor = 0;
factor = DNS_ADB_RTTADJDEFAULT;
} else {
/*
* We don't have an RTT for this query. Maybe the packet
......@@ -280,10 +280,9 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
if (rtt > 10000000)
rtt = 10000000;
/*
* We set 'factor' to 1, so that we will replace the current
* RTT.
* Replace the current RTT with our value.
*/
factor = 1;
factor = DNS_ADB_RTTADJREPLACE;
}
dns_adb_adjustsrtt(fctx->res->view->adb, query->addrinfo, rtt, factor);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment