Re: unwind(8): give the first available resolver strategy a bit more time

2021-10-22 Thread Klemens Nanni
On Fri, Oct 22, 2021 at 06:10:32PM +0200, Florian Obser wrote:
> 
> unwind(8) gives the most preferred resolver strategy a bit more time
> (200ms) to answer before trying the next strategy. However, we need to
> skip strategies that are not available. In the default configuration,
> without a config file, unwind(8) would give DoT 200ms more time, but no
> DoT forwarders are known, so this is useless.

OK kn



unwind(8): give the first available resolver strategy a bit more time

2021-10-22 Thread Florian Obser


unwind(8) gives the most preferred resolver strategy a bit more time
(200ms) to answer before trying the next strategy. However, we need to
skip strategies that are not available. In the default configuration,
without a config file, unwind(8) would give DoT 200ms more time, but no
DoT forwarders are known, so this is useless.

OK?

diff --git resolver.c resolver.c
index 81485b230fa..1eb505512e4 100644
--- resolver.c
+++ resolver.c
@@ -772,6 +772,7 @@ try_next_resolver(struct running_query *rq)
struct timespec  tp, elapsed;
struct timeval   tv = {0, 0};
int64_t  ms;
+   int  i;
 
while(rq->next_resolver < rq->res_pref.len &&
((res = resolvers[rq->res_pref.types[rq->next_resolver]]) == NULL ||
@@ -804,7 +805,12 @@ try_next_resolver(struct running_query *rq)
ms = res->median;
if (ms > NEXT_RES_MAX)
ms = NEXT_RES_MAX;
-   if (res->type == resolver_conf->res_pref.types[0])
+
+   /* skip over unavailable resolvers in preferences */
+   for (i = 0; i < resolver_conf->res_pref.len &&
+resolvers[resolver_conf->res_pref.types[i]] == NULL; i++)
+   ;
+   if (res->type == resolver_conf->res_pref.types[i])
tv.tv_usec = 1000 * (PREF_RESOLVER_MEDIAN_SKEW + ms);
else
tv.tv_usec = 1000 * ms;

-- 
I'm not entirely sure you are real.