summaryrefslogtreecommitdiff
path: root/services/cache
diff options
context:
space:
mode:
Diffstat (limited to 'services/cache')
-rw-r--r--services/cache/dns.c19
-rw-r--r--services/cache/dns.h12
2 files changed, 31 insertions, 0 deletions
diff --git a/services/cache/dns.c b/services/cache/dns.c
index f2a04a227cb9..c663b8e8b9a2 100644
--- a/services/cache/dns.c
+++ b/services/cache/dns.c
@@ -795,3 +795,22 @@ dns_cache_store(struct module_env* env, struct query_info* msgqinf,
}
return 1;
}
+
+int
+dns_cache_prefetch_adjust(struct module_env* env, struct query_info* qinfo,
+ time_t adjust)
+{
+ struct msgreply_entry* msg;
+ msg = msg_cache_lookup(env, qinfo->qname, qinfo->qname_len,
+ qinfo->qtype, qinfo->qclass, *env->now, 1);
+ if(msg) {
+ struct reply_info* rep = (struct reply_info*)msg->entry.data;
+ if(rep) {
+ rep->prefetch_ttl += adjust;
+ lock_rw_unlock(&msg->entry.lock);
+ return 1;
+ }
+ lock_rw_unlock(&msg->entry.lock);
+ }
+ return 0;
+}
diff --git a/services/cache/dns.h b/services/cache/dns.h
index a7a6190cffba..05a3e6296543 100644
--- a/services/cache/dns.h
+++ b/services/cache/dns.h
@@ -179,4 +179,16 @@ struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype,
int dns_msg_authadd(struct dns_msg* msg, struct regional* region,
struct ub_packed_rrset_key* rrset, time_t now);
+/**
+ * Adjust the prefetch_ttl for a cached message. This adds a value to the
+ * prefetch ttl - postponing the time when it will be prefetched for future
+ * incoming queries.
+ * @param env: module environment with caches and time.
+ * @param qinfo: query info for the query that needs adjustment.
+ * @param adjust: time in seconds to add to the prefetch_leeway.
+ * @return false if not in cache. true if added.
+ */
+int dns_cache_prefetch_adjust(struct module_env* env, struct query_info* qinfo,
+ time_t adjust);
+
#endif /* SERVICES_CACHE_DNS_H */