Convert total timeout to per-query (#467)

On Apple platforms, libresolv reports the total timeout in retrans, not the per-query time. This patch undoes that math to get the per-query time, which is what c-ares expects. This is not perfect because libresolv is inconsistent on whether the timeout is multiplied by retry or retry+1, but I don't see any way to distinguish these cases.

Fix By: Marc Aldorasi (@marc-groundctl)
pull/474/head
marc-groundctl 3 years ago committed by GitHub
parent e20215ab93
commit afee6748b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/lib/ares_init.c

@ -1347,8 +1347,12 @@ static int init_by_resolv_conf(ares_channel channel)
channel->tries = res.retry; channel->tries = res.retry;
if (channel->rotate == -1) if (channel->rotate == -1)
channel->rotate = res.options & RES_ROTATE; channel->rotate = res.options & RES_ROTATE;
if (channel->timeout == -1) if (channel->timeout == -1) {
channel->timeout = res.retrans * 1000; channel->timeout = res.retrans * 1000;
#ifdef __APPLE__
channel->timeout /= (res.retry + 1) * (res.nscount > 0 ? res.nscount : 1);
#endif
}
res_ndestroy(&res); res_ndestroy(&res);
} }

Loading…
Cancel
Save