Skip to content
Snippets Groups Projects
Verified Commit a23bb067 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Tomas Krizek
Browse files

lib/selection: be more careful with RO transactions

They probably couldn't hang open for long, as each client request
should cause some cache-searching and thus close it, and even with
queries stopping I haven't managed to find a case where it would be
left open but... it's nicer to clean up and it should be very cheap.
parent c32dee26
Branches
Tags
1 merge request!1184lib/selection: be more careful with RO transactions
Pipeline #83853 failed with stages
in 44 minutes and 46 seconds
......@@ -254,6 +254,9 @@ uint8_t *ip_to_bytes(const union inaddr *src, size_t len);
/**
* @internal Fetch per-address information from various sources.
*
* Note that this opens a RO cache transaction; the callee is responsible
* for its closing not too long afterwards (e.g. calling kr_cache_commit).
*/
void update_address_state(struct address_state *state, union inaddr *address,
size_t address_len, struct kr_query *qry);
......@@ -53,7 +53,7 @@ void forward_choose_transport(struct kr_query *qry,
default:
kr_assert(false);
*transport = NULL;
return;
goto cleanup;
}
struct address_state *addr_state = &local_state->addr_states[i];
......@@ -94,6 +94,8 @@ void forward_choose_transport(struct kr_query *qry,
qry->flags.TCP = (*transport)->protocol == KR_TRANSPORT_TCP
|| (*transport)->protocol == KR_TRANSPORT_TLS;
}
cleanup:
kr_cache_commit(&qry->request->ctx->cache);
}
void forward_error(struct kr_query *qry, const struct kr_transport *transport,
......
......@@ -127,6 +127,7 @@ static void unpack_state_from_zonecut(struct iter_local_state *local_state,
}
}
trie_it_free(it);
kr_cache_commit(&qry->request->ctx->cache);
}
static int get_valid_addresses(struct iter_local_state *local_state,
......
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