diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2019-12-06 16:41:12 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2019-12-06 16:41:12 +0000 |
commit | 3d67767391af5654a900c0f5844991b2a4786cd0 (patch) | |
tree | ab2ec0a229da8b5dadf64a7dfb44533df0a81121 /sbin/unwind/resolver.c | |
parent | 3a6428ff6fbf22ebe9480cdeb2b0cb6c73a1dae1 (diff) |
Use the middle of the histogram bar in the median computations
instead of the right-hand side; ok florian@
Diffstat (limited to 'sbin/unwind/resolver.c')
-rw-r--r-- | sbin/unwind/resolver.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c index 47cc705f750..e11483059bf 100644 --- a/sbin/unwind/resolver.c +++ b/sbin/unwind/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.100 2019/12/05 15:50:20 otto Exp $ */ +/* $OpenBSD: resolver.c,v 1.101 2019/12/06 16:41:11 otto Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -76,6 +76,7 @@ * best and still be picked */ #define PREF_RESOLVER_MEDIAN_SKEW 200 /* 200 ms */ +#define NEXT_RES_MAX 2000 /* 2000 ms */ #define DOUBT_NXDOMAIN_SEC (5 * 60) /* 5 minutes */ @@ -789,8 +790,8 @@ try_next_resolver(struct running_query *rq) clock_gettime(CLOCK_MONOTONIC, &query_imsg->tp); ms = res->median; - if (ms == INT64_MAX) - ms = 2000; + if (ms > NEXT_RES_MAX) + ms = NEXT_RES_MAX; if (res->type == resolver_conf->res_pref.types[0]) tv.tv_usec = 1000 * (PREF_RESOLVER_MEDIAN_SKEW + ms); else @@ -1997,7 +1998,9 @@ histogram_median(int64_t *histogram) break; } - return histogram_limits[i]; + if (i >= nitems(histogram_limits) - 1) + return INT64_MAX; + return (histogram_limits[i - 1] + histogram_limits[i]) / 2; } void |