return;
}
+ /* Rotate previous addresses to the right. */
+ memmove(ns->addr + pos + 1, ns->addr + pos, (KR_NSREP_MAXADDR - pos - 1) * sizeof(ns->addr[0]));
+
switch(addr_len) {
case sizeof(struct in_addr):
ADDR_SET(ns->addr[pos].ip4.sin, AF_INET, addr, addr_len); break;
size_t len = pack_obj_len(addr[i]);
update_nsrep(ns, i, addr_val, len);
} else {
- update_nsrep(ns, i, NULL, 0);
+ break;
}
}
}
unsigned *cached = rttcache ? lru_get(rttcache, val, len) : NULL;
unsigned addr_score = (cached) ? *cached : KR_NS_GLUED;
if (addr_score < score + favour) {
- /* Shake down previous contenders, last one is always unused */
- for (size_t i = KR_NSREP_MAXADDR - 2; i > 0; --i)
+ /* Shake down previous contenders */
+ for (size_t i = KR_NSREP_MAXADDR - 1; i > 0; --i)
addr[i] = addr[i - 1];
addr[0] = it;
score = addr_score;
* The fastest NS is preferred by workers until it is depleted (timeouts or degrades),
* at the same time long distance scouts probe other sources (low probability).
* Servers on TIMEOUT (depleted) can be probed by the dice roll only */
- if (score < ns->score && (qry->flags & QUERY_NO_THROTTLE || score < KR_NS_TIMEOUT)) {
+ if (score <= ns->score && (qry->flags & QUERY_NO_THROTTLE || score < KR_NS_TIMEOUT)) {
update_nsrep_set(ns, (const knot_dname_t *)k, addr_choice, score);
ns->reputation = reputation;
} else {
typedef lru_hash(unsigned) kr_nsrep_lru_t;
/* Maximum count of addresses probed in one go (last is left empty) */
-#define KR_NSREP_MAXADDR 3
+#define KR_NSREP_MAXADDR 4
/**
* Name server representation.