mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-24 00:29:58 -05:00
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:
parent
1a9238ca5f
commit
1065ff7c17
5 changed files with 20 additions and 7 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
29 May 2007: Wouter
|
29 May 2007: Wouter
|
||||||
- routines to lock and unlock array of rrsets moved to cache/rrset.
|
- routines to lock and unlock array of rrsets moved to cache/rrset.
|
||||||
- lookup message from msg cache (and copy to region).
|
- 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
|
25 May 2007: Wouter
|
||||||
- Acknowledge use of unbound-java code in iterator. Nicer readme.
|
- Acknowledge use of unbound-java code in iterator. Nicer readme.
|
||||||
|
|
|
||||||
12
services/cache/dns.c
vendored
12
services/cache/dns.c
vendored
|
|
@ -68,12 +68,18 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
|
||||||
hashvalue_t hash, struct reply_info* rep)
|
hashvalue_t hash, struct reply_info* rep)
|
||||||
{
|
{
|
||||||
struct msgreply_entry* e;
|
struct msgreply_entry* e;
|
||||||
uint32_t now = time(NULL);
|
uint32_t now = time(NULL), ttl = rep->ttl;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
/* store RRsets */
|
/* 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);
|
reply_info_set_ttls(rep, now);
|
||||||
store_rrsets(env, 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,
|
/* we do not store the message, but we did store the RRs,
|
||||||
* which could be useful for delegation information */
|
* which could be useful for delegation information */
|
||||||
verbose(VERB_ALGO, "TTL 0: dropped msg from cache");
|
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;
|
return NULL;
|
||||||
ck->entry.data = d;
|
ck->entry.data = d;
|
||||||
packed_rrset_ptr_fixup(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++)
|
for(i=0; i<d->count + d->rrsig_count; i++)
|
||||||
d->rr_ttl[i] -= now;
|
d->rr_ttl[i] -= now;
|
||||||
d->ttl -= now;
|
d->ttl -= now;
|
||||||
|
|
|
||||||
3
services/cache/rrset.c
vendored
3
services/cache/rrset.c
vendored
|
|
@ -217,7 +217,8 @@ rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow)
|
||||||
continue; /* only lock items once */
|
continue; /* only lock items once */
|
||||||
lock_rw_rdlock(&ref[i].key->entry.lock);
|
lock_rw_rdlock(&ref[i].key->entry.lock);
|
||||||
if(ref[i].id != ref[i].key->id || timenow >
|
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 */
|
/* failure! rollback our readlocks */
|
||||||
rrset_array_unlock(ref, i+1);
|
rrset_array_unlock(ref, i+1);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -393,12 +393,15 @@ reply_info_set_ttls(struct reply_info* rep, uint32_t timenow)
|
||||||
rep->ttl += timenow;
|
rep->ttl += timenow;
|
||||||
for(i=0; i<rep->rrset_count; i++) {
|
for(i=0; i<rep->rrset_count; i++) {
|
||||||
struct packed_rrset_data* data = (struct packed_rrset_data*)
|
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;
|
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;
|
data->rr_ttl[j] += timenow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc)
|
reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc)
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,7 @@ void reply_info_sortref(struct reply_info* rep);
|
||||||
/**
|
/**
|
||||||
* Set TTLs inside the replyinfo to absolute values.
|
* 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.
|
* @param timenow: the current time.
|
||||||
*/
|
*/
|
||||||
void reply_info_set_ttls(struct reply_info* rep, uint32_t timenow);
|
void reply_info_set_ttls(struct reply_info* rep, uint32_t timenow);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue