]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
selection: limit timeout from above and edit the test accordingly
authorŠtěpán Balážik <stepan.balazik@nic.cz>
Thu, 3 Sep 2020 10:39:03 +0000 (12:39 +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
tests/config/test_utils.lua

index ee31ae3cdb4be559041930a46e463af0febd6433..c22de5ad620599910be00e5236ea79639426e11d 100644 (file)
@@ -37,6 +37,8 @@ void *prefix_key(const uint8_t *ip, size_t len) {
 #undef PREFIX
 
 #define DEFAULT_TIMEOUT 400
+#define MAX_TIMEOUT 10000
+
 const struct rtt_state default_rtt_state = {0, DEFAULT_TIMEOUT/4, 0};
 
 struct rtt_state get_rtt_state(const uint8_t *ip, size_t len, struct kr_cache *cache) {
@@ -109,7 +111,11 @@ bool no_rtt_info(struct rtt_state s) {
 // This is verbatim (minus the default timeout value and minimal variance) RFC2988, sec. 2
 int32_t calc_timeout(struct rtt_state state) {
        int32_t timeout = state.srtt + MAX(4 * state.variance, MINIMAL_TIMEOUT_ADDITION);
-       return timeout * (1 << state.consecutive_timeouts);
+       timeout = timeout * (1 << state.consecutive_timeouts);
+       if (timeout > MAX_TIMEOUT) {
+               return MAX_TIMEOUT;
+       }
+       return timeout;
 }
 
 // This is verbatim RFC2988, sec. 2
index afc713b282dddf4623e2f437d73c410c92133279..e685dcce8e5cf0a1269f39ded02e552aafd6d0b8 100644 (file)
@@ -83,7 +83,7 @@ function M.check_answer(desc, qname, qtype, expected_rcode, expected_rdata)
        end
        resolve(qname, qtype, kres.class.IN, {}, callback)
 
-       for delay = 0.1, 4, 0.5 do -- total max 14.9s in 8 steps
+       for delay = 0.1, 5, 0.5 do -- total max 23.5s in 9 steps
                if done then return end
                worker.sleep(delay)
        end