]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
selection: fix race condition when updating rtt cache
authorŠtěpán Balážik <stepan.balazik@nic.cz>
Sat, 29 Aug 2020 12:32:57 +0000 (14:32 +0200)
committerŠtěpán Balážik <stepan.balazik@nic.cz>
Thu, 15 Oct 2020 11:22:21 +0000 (13:22 +0200)
lib/selection.c

index 638fc5035785b5be648b039fe5f2c21ab17f8660..4d2f31153f93a7d97867b5e64e11631e8e683bd1 100644 (file)
@@ -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) {