0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::net::dns: Perturb the minimum TTL to avoid groupings on expiration.

This commit is contained in:
Jason Volk 2022-08-11 21:38:36 -07:00
parent 26d34224b6
commit 5ce08521d5

View file

@ -239,24 +239,29 @@ bool
ircd::net::dns::expired(const json::object &rr, ircd::net::dns::expired(const json::object &rr,
const time_t &rr_ts) const time_t &rr_ts)
{ {
const seconds &min_seconds const seconds base
{
cache::min_ttl
};
const seconds &err_seconds
{
cache::error_ttl
};
const time_t &min
{ {
is_error(rr)? is_error(rr)?
err_seconds.count(): seconds(cache::error_ttl):
min_seconds.count() seconds(cache::min_ttl)
}; };
return expired(rr, rr_ts, min); const pair<u64> perturb_range
{
1, base.count() / 3
};
const seconds perturb
{
rand::integer(perturb_range.first, perturb_range.second)
};
const seconds min
{
base + perturb
};
return expired(rr, rr_ts, min.count());
} }
bool bool