From dc863957bc89e9b5a1c2a679bc2b6230d28df5ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Sat, 29 Aug 2020 14:32:57 +0200 Subject: [PATCH] selection: fix race condition when updating rtt cache --- lib/selection.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/selection.c b/lib/selection.c index 638fc5035..4d2f31153 100644 --- a/lib/selection.c +++ b/lib/selection.c @@ -255,8 +255,10 @@ void update_rtt(struct kr_query *qry, struct address_state *addr_state, const st } struct kr_cache *cache = &qry->request->ctx->cache; - struct rtt_state new_rtt_state = calc_rtt_state(addr_state->rtt_state, rtt); + uint8_t *address = ip_to_bytes(&transport->address, transport->address_len); + struct rtt_state cur_rtt_state = get_rtt_state(address, transport->address_len, cache); + struct rtt_state new_rtt_state = calc_rtt_state(cur_rtt_state, rtt); put_rtt_state(address, transport->address_len, new_rtt_state, cache); WITH_VERBOSE(qry) { -- 2.47.2