Commit beb2b4f1 authored by Michael Graff's avatar Michael Graff
Browse files

Allow the srtt value to be adjusted, and update the goodness and srtt when they are modified

parent ca924f70
......@@ -202,7 +202,6 @@ main(int argc, char **argv)
/*
* Mark one entry as lame, then look this name up again.
*/
ai = ISC_LIST_HEAD(handle->list);
INSIST(ai != NULL);
ai = ISC_LIST_NEXT(ai, link);
......@@ -210,6 +209,17 @@ main(int argc, char **argv)
result = dns_adb_marklame(adb, ai, &name1, now + 10 * 60);
check_result(result, "dns_adb_marklame()");
/*
* And while we're here, add some goodness to it and tweak up
* the srtt value a bit.
*/
dns_adb_adjustgoodness(adb, ai, 100);
dns_adb_adjustgoodness(adb, ai, -50);
INSIST(ai->goodness == 50);
dns_adb_adjustsrtt(adb, ai, 10000, 0);
dns_adb_adjustsrtt(adb, ai, 10, 10);
INSIST(ai->srtt == 2251);
dns_adb_done(adb, &handle);
/*
......
......@@ -1731,6 +1731,7 @@ dns_adb_adjustgoodness(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
int bucket;
int old_goodness, new_goodness;
REQUIRE(DNS_ADB_VALID(adb));
REQUIRE(DNS_ADBADDRINFO_VALID(addr));
if (goodness_adjustment == 0)
......@@ -1754,7 +1755,30 @@ dns_adb_adjustgoodness(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
}
addr->entry->goodness = new_goodness;
addr->goodness = new_goodness;
UNLOCK(&adb->entrylocks[bucket]);
}
void
dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
unsigned int rtt, unsigned int factor)
{
int bucket;
unsigned int new_srtt;
REQUIRE(DNS_ADB_VALID(adb));
REQUIRE(DNS_ADBADDRINFO_VALID(addr));
if (factor == 0)
factor = 4;
bucket = addr->entry->lock_bucket;
LOCK(&adb->entrylocks[bucket]);
new_srtt = (addr->entry->srtt * (factor - 1) + rtt) / factor;
addr->entry->srtt = new_srtt;
addr->srtt = new_srtt;
UNLOCK(&adb->entrylocks[bucket]);
}
......@@ -402,19 +402,43 @@ dns_adb_adjustgoodness(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
* Note:
*
* Goodness values are silently clamped to INT_MAX and INT_MIN.
*
* The goodness in addr will be updated to reflect the new global
* goodness value. This may include changes made by others.
*/
void
dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
unsigned int rtt, unsigned int factor);
/*
* Mix the round trip time into the existing smoothed rtt. The formula used
* (where srtt is the existing rtt value, and rtt and factor are arguments to
* this function):
*
* new_srtt = (srtt * (factor - 1) + rtt) / factor
*
* Requires:
*
* adb be valid.
*
* addr be valid.
*
* Note:
*
* If factor is zero, 4 will be used.
*
* The srtt in addr will be updated to reflect the new global
* srtt value. This may include changes made by others.
*/
/*
* XXX Need functions/macros to:
*
* Remove an address from a handle's linked list. This is needed
* because the data pointed to by a dns_adbaddr_t is reference counted.
*
* Adjust the goodness, both local and globally.
*
* set/clear various flags. (Which flags?)
*
* Mix in measured RTT values.
*/
ISC_LANG_ENDDECLS
......
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