}
}
-#define ERROR_LIMIT 2
-
// Performs the actual selection (currently epsilon-greedy with epsilon = 0.05).
struct kr_transport *choose_transport(struct choice choices[],
int choices_len,
// EXPLOIT
shuffle_choices(choices, choices_len);
qsort(choices, choices_len, sizeof(struct choice), cmp_choices);
- if (choices[0].address_state->error_count > ERROR_LIMIT) {
- return NULL;
- } else {
- choice = 0;
- }
+ choice = 0;
}
unsigned timeout = calc_timeout(choices[choice].address_state->rtt_state);
#include "lib/cache/api.h"
+#define ERROR_LIMIT_PER_SERVER 2
+
/**
* These errors are to be reported as feedback to server selection.
* See `kr_server_selection::error` for more details.
check_tcp_connections(addr_state, qry->request, &address->ip);
check_network_settings(addr_state, addr_len, qry->flags.NO_IPV4, qry->flags.NO_IPV6);
- if(addr_state->generation == -1) {
+ if(addr_state->generation == -1 || addr_state->error_count >= ERROR_LIMIT_PER_SERVER) {
continue;
}
addr_state->forward_index = i;
size_t address_len;
uint8_t* address = (uint8_t *)trie_it_key(it, &address_len);
struct address_state *address_state = (struct address_state *)*trie_it_val(it);
- if (address_state->generation == local_state->generation) {
+ if (address_state->generation == local_state->generation &&
+ address_state->error_count < ERROR_LIMIT_PER_SERVER) {
choices[valid_addresses] = (struct choice){
.address = address,
.address_len = address_len,