]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup cast and fixup TTL increase for duplicate rrset messages.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 29 May 2007 12:26:45 +0000 (12:26 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 29 May 2007 12:26:45 +0000 (12:26 +0000)
git-svn-id: file:///svn/unbound/trunk@344 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/cache/dns.c
services/cache/rrset.c
util/data/msgreply.c
util/data/msgreply.h

index d53344c2fdd4f4a7d7f98f57cad34a03a14fbee2..9bb17f4a8051602d0eef9457beed60fec013ff81 100644 (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.
index 201e32b815d9405bac41074be816055e189a3848..addf7e94d9465c400a01b9ed308f9b82da2b1de9 100644 (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;
index 2d2e4f1e5be8265d879d4c2d68fc9cdae8a2b759..a40f0f63d3099558cc1b2a1a7e65d3952feae403 100644 (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;
index abd9bda9469a32b1be2f75d7e31d10892026152a..f48b221b29033b5e1c3fecb06e88f090b561a0af 100644 (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;
+               }
        }
 }
 
index 566a8707e05ccc482db15d7f552886496d777c28..8bf99dbc5bb4696f91681a5bbe44f46572b32ad4 100644 (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);