From: Wouter Wijngaards Date: Tue, 29 May 2007 12:26:45 +0000 (+0000) Subject: fixup cast and fixup TTL increase for duplicate rrset messages. X-Git-Tag: release-0.4~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1065ff7c172ecb2b1f1dbc15c25d998ed4c34ffe;p=thirdparty%2Funbound.git fixup cast and fixup TTL increase for duplicate rrset messages. git-svn-id: file:///svn/unbound/trunk@344 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index d53344c2f..9bb17f4a8 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,8 @@ 29 May 2007: Wouter - routines to lock and unlock array of rrsets moved to cache/rrset. - lookup message from msg cache (and copy to region). + - fixed cast error in dns msg lookup. + - message with duplicate rrset does not increase its TTLs twice. 25 May 2007: Wouter - Acknowledge use of unbound-java code in iterator. Nicer readme. diff --git a/services/cache/dns.c b/services/cache/dns.c index 201e32b81..addf7e94d 100644 --- a/services/cache/dns.c +++ b/services/cache/dns.c @@ -68,12 +68,18 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, hashvalue_t hash, struct reply_info* rep) { struct msgreply_entry* e; - uint32_t now = time(NULL); + uint32_t now = time(NULL), ttl = rep->ttl; + size_t i; /* store RRsets */ + for(i=0; irrset_count; i++) { + rep->ref[i].key = rep->rrsets[i]; + rep->ref[i].id = rep->rrsets[i]->id; + } + reply_info_sortref(rep); reply_info_set_ttls(rep, now); store_rrsets(env, rep, now); - if(rep->ttl == 0) { + if(ttl == 0) { /* we do not store the message, but we did store the RRs, * which could be useful for delegation information */ verbose(VERB_ALGO, "TTL 0: dropped msg from cache"); @@ -259,7 +265,7 @@ copy_rrset(struct ub_packed_rrset_key* key, struct region* region, return NULL; ck->entry.data = d; packed_rrset_ptr_fixup(d); - /* make TTLs relative */ + /* make TTLs relative - once per rrset */ for(i=0; icount + d->rrsig_count; i++) d->rr_ttl[i] -= now; d->ttl -= now; diff --git a/services/cache/rrset.c b/services/cache/rrset.c index 2d2e4f1e5..a40f0f63d 100644 --- a/services/cache/rrset.c +++ b/services/cache/rrset.c @@ -217,7 +217,8 @@ rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow) continue; /* only lock items once */ lock_rw_rdlock(&ref[i].key->entry.lock); if(ref[i].id != ref[i].key->id || timenow > - ((struct reply_info*)(ref[i].key->entry.data))->ttl) { + ((struct packed_rrset_data*)(ref[i].key->entry.data)) + ->ttl) { /* failure! rollback our readlocks */ rrset_array_unlock(ref, i+1); return 0; diff --git a/util/data/msgreply.c b/util/data/msgreply.c index abd9bda94..f48b221b2 100644 --- a/util/data/msgreply.c +++ b/util/data/msgreply.c @@ -393,10 +393,13 @@ reply_info_set_ttls(struct reply_info* rep, uint32_t timenow) rep->ttl += timenow; for(i=0; irrset_count; i++) { struct packed_rrset_data* data = (struct packed_rrset_data*) - rep->rrsets[i]->entry.data; + rep->ref[i].key->entry.data; + if(i>0 && rep->ref[i].key == rep->ref[i-1].key) + continue; data->ttl += timenow; - for(j=0; jcount + data->rrsig_count; j++) + for(j=0; jcount + data->rrsig_count; j++) { data->rr_ttl[j] += timenow; + } } } diff --git a/util/data/msgreply.h b/util/data/msgreply.h index 566a8707e..8bf99dbc5 100644 --- a/util/data/msgreply.h +++ b/util/data/msgreply.h @@ -203,7 +203,8 @@ void reply_info_sortref(struct reply_info* rep); /** * Set TTLs inside the replyinfo to absolute values. - * @param rep: reply info. rrsets must be filled in. + * @param rep: reply info. rrsets must be filled in. + * Also refs must be filled in. * @param timenow: the current time. */ void reply_info_set_ttls(struct reply_info* rep, uint32_t timenow);