other threads from picking up the wrong data. The module restores
the previous no_cache_store setting when the the module is finished.
- Fix #4208: 'stub-no-cache' and 'forward-no-cache' not work.
+ - New and better fix for Fix #4193: Fix that prefetch failure does
+ not overwrite valid cache entry with SERVFAIL.
26 November 2018: Wouter
- Fix to not set GLOB_NOSORT so the unbound.conf include: files are
if(!qstate->no_cache_store) {
/* store in cache */
struct reply_info err;
- if(qstate->prefetch_leeway > 0) {
+ if(qstate->prefetch_leeway > NORR_TTL) {
verbose(VERB_ALGO, "error response for prefetch in cache");
/* attempt to adjust the cache entry prefetch */
if(dns_cache_prefetch_adjust(qstate->env, &qstate->qinfo,
/* serving expired contents, but nothing is cached
* at all, so the servfail cache entry is useful
* (stops waste of time on this servfail NORR_TTL) */
+ } else {
+ /* don't overwrite existing (non-expired) data in
+ * cache with a servfail */
+ struct msgreply_entry* msg;
+ if((msg=msg_cache_lookup(qstate->env,
+ qstate->qinfo.qname, qstate->qinfo.qname_len,
+ qstate->qinfo.qtype, qstate->qinfo.qclass,
+ qstate->query_flags, *qstate->env->now, 0))
+ != NULL) {
+ struct reply_info* rep = (struct reply_info*)
+ msg->entry.data;
+ if(FLAGS_GET_RCODE(rep->flags) ==
+ LDNS_RCODE_NOERROR ||
+ FLAGS_GET_RCODE(rep->flags) ==
+ LDNS_RCODE_NXDOMAIN) {
+ /* we have a good entry,
+ * don't overwrite */
+ lock_rw_unlock(&msg->entry.lock);
+ return error_response(qstate, id, rcode);
+ }
+ lock_rw_unlock(&msg->entry.lock);
+ }
+
}
memset(&err, 0, sizeof(err));
err.flags = (uint16_t)(BIT_QR | BIT_RA);