Commit 22bd9fb5 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Set DNS cache expire date for error and ok statuses only

parent e007b6b0
......@@ -65,7 +65,12 @@ ResolverEntry DNSTracker::make_entry(std::unique_ptr<DualDNSResolver> resolv,
ent.resolv = std::move(resolv);
ent.host = std::move(host);
ent.status = status;
ent.expiry = ev_now(loop_) + dnsconf.timeout.cache;
switch (status) {
case DNS_STATUS_ERROR:
case DNS_STATUS_OK:
ent.expiry = ev_now(loop_) + dnsconf.timeout.cache;
break;
}
if (result) {
ent.result = *result;
}
......@@ -75,8 +80,16 @@ ResolverEntry DNSTracker::make_entry(std::unique_ptr<DualDNSResolver> resolv,
void DNSTracker::update_entry(ResolverEntry &ent,
std::unique_ptr<DualDNSResolver> resolv,
int status, const Address *result) {
auto &dnsconf = get_config()->dns;
ent.resolv = std::move(resolv);
ent.status = status;
switch (status) {
case DNS_STATUS_ERROR:
case DNS_STATUS_OK:
ent.expiry = ev_now(loop_) + dnsconf.timeout.cache;
break;
}
if (result) {
ent.result = *result;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment