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.
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");
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;
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;
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;
+ }
}
}
/**
* 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);