static inline void
fctx_setretryinterval(fetchctx_t *fctx, unsigned int rtt) {
unsigned int seconds;
unsigned int us;
/*
* We retry every .8 seconds the first two times through the address
* list, and then we do exponential back-off.
*/
if (fctx->restarts < 3)
us = 800000;
else
us = (800000 << (fctx->restarts - 2));
/*
* Double the round-trip time.
*/
rtt *= 2;
/*
* Always wait for at least the doubled round-trip time.
*/
if (us < rtt)
us = rtt;
/*
* But don't ever wait for more than 10 seconds.
*/
if (us > 10000000)
us = 10000000;
seconds = us / 1000000;
us -= seconds * 1000000;
isc_interval_set(&fctx->interval, seconds, us * 1000);
}
BIND9 递归查询超时机制
最新推荐文章于 2024-08-27 15:38:47 发布
本文详细阐述了如何根据网络请求的失败次数调整重试间隔时间,包括初始重试时间设置、指数级增长的重试策略,以及确保重试等待时间不超过固定上限的逻辑。此实现旨在优化网络请求的可靠性与效率。
2696

被折叠的 条评论
为什么被折叠?



