ref: 66a2bb218e4fdef0004bd9d1947bd38e83e860e3
parent: db74ee87b79a888ccef57d98c73147946aa291b6
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Jun 20 22:27:10 EDT 2013
ndb/dns: avoid duplicate entries for db records dnauthdb() would relabel expired rr's as rr->db == 0 to make them get garbage collected by dnage(). but this doesnt work due to dn->keep and also causes the deduplication to fail on rrattach() as rrattach1() handles rr->dn/rr->auth as separate name spaces. this causes duplicate entries in the rr's when ndb gets gets changed. to fix, we just delete the expired (removed from ndb) rr's immidiately in dnauthdb() instead of trying trick dnage() to garbage collect it.
--- a/sys/src/cmd/ndb/dn.c
+++ b/sys/src/cmd/ndb/dn.c
@@ -597,7 +597,7 @@
/*
* mark all local db records about my area as authoritative,
- * time out any others
+ * delete timed out ones
*/
void
dnauthdb(void)
@@ -606,7 +606,7 @@
ulong minttl;
Area *area;
DN *dp;
- RR *rp;
+ RR *rp, **l;
lock(&dnlock);
@@ -614,8 +614,13 @@
for(i = 0; i < HTLEN; i++)
for(dp = ht[i]; dp; dp = dp->next){area = inmyarea(dp->name);
- for(rp = dp->rr; rp; rp = rp->next)
+ l = &dp->rr;
+ for(rp = *l; rp; rp = *l){ if(rp->db){+ if(rp->expire == 0){+ rrdelhead(l);
+ continue;
+ }
if(area){minttl = area->soarr->soa->minttl;
if(rp->ttl < minttl)
@@ -622,11 +627,9 @@
rp->ttl = minttl;
rp->auth = 1;
}
- if(rp->expire == 0){- rp->db = 0;
- dp->referenced = now-Reserved-1;
- }
}
+ l = &rp->next;
+ }
}
unlock(&dnlock);
--
⑨