diff options
author | Lukáš Ondráček <lukas.ondracek@nic.cz> | 2024-06-18 13:16:57 +0200 |
---|---|---|
committer | Lukáš Ondráček <lukas.ondracek@nic.cz> | 2024-06-18 13:16:57 +0200 |
commit | b74cf1fb2ef41f51414a79ada25b54f5ba4c18aa (patch) | |
tree | 689b61c6c178330d7abbd12f8c955bfb22ab5a3a /lib/kru.inc.c | |
parent | treewide: utilize _Alignas, as it's standard C11 (diff) | |
download | knot-resolver-b74cf1fb2ef41f51414a79ada25b54f5ba4c18aa.tar.xz knot-resolver-b74cf1fb2ef41f51414a79ada25b54f5ba4c18aa.zip |
lib/kru: add optional arg prefix_out for logging
Diffstat (limited to 'lib/kru.inc.c')
-rw-r--r-- | lib/kru.inc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/kru.inc.c b/lib/kru.inc.c index b67d3237..53a9f97b 100644 --- a/lib/kru.inc.c +++ b/lib/kru.inc.c @@ -565,7 +565,7 @@ static uint8_t kru_limited_multi_prefix_or(struct kru *kru, uint32_t time_now, u } static uint16_t kru_load_multi_prefix_max(struct kru *kru, uint32_t time_now, uint8_t namespace, - uint8_t key[static 16], uint8_t *prefixes, kru_price_t *prices, size_t queries_cnt) + uint8_t key[static 16], uint8_t *prefixes, kru_price_t *prices, size_t queries_cnt, uint8_t *prefix_out) { struct query_ctx ctx[queries_cnt]; @@ -583,10 +583,18 @@ static uint16_t kru_load_multi_prefix_max(struct kru *kru, uint32_t time_now, ui } } + uint8_t prefix = 0; uint16_t max_load = 0; for (size_t i = 0; i < queries_cnt; i++) { - max_load = MAX(max_load, ctx[i].final_load_value); + if (max_load < ctx[i].final_load_value) { + max_load = ctx[i].final_load_value; + prefix = prefixes[i]; + } + } + if (prefix_out) { + *prefix_out = prefix; } + return max_load; } |