fixup cast and fixup TTL increase for duplicate rrset messages.

git-svn-id: file:///svn/unbound/trunk@344 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-05-29 12:26:45 +00:00
parent 1a9238ca5f
commit 1065ff7c17
5 changed files with 20 additions and 7 deletions

View File

@ -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.

12
services/cache/dns.c vendored
View File

@ -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; i<rep->rrset_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; i<d->count + d->rrsig_count; i++)
d->rr_ttl[i] -= now;
d->ttl -= now;

View File

@ -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;

View File

@ -393,10 +393,13 @@ reply_info_set_ttls(struct reply_info* rep, uint32_t timenow)
rep->ttl += timenow;
for(i=0; i<rep->rrset_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; j<data->count + data->rrsig_count; j++)
for(j=0; j<data->count + data->rrsig_count; j++) {
data->rr_ttl[j] += timenow;
}
}
}

View File

@ -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);