From 41208add722b0e572c1fae65b4184088a61ee3b1 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 21 Jun 2013 02:27:10 +0200 Subject: [PATCH] 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. --- sys/src/cmd/ndb/dn.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/src/cmd/ndb/dn.c b/sys/src/cmd/ndb/dn.c index e91183c37..ffc55ef8f 100644 --- a/sys/src/cmd/ndb/dn.c +++ b/sys/src/cmd/ndb/dn.c @@ -597,7 +597,7 @@ dnagedb(void) /* * 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 @@ dnauthdb(void) ulong minttl; Area *area; DN *dp; - RR *rp; + RR *rp, **l; lock(&dnlock); @@ -614,19 +614,22 @@ dnauthdb(void) 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) rp->ttl = minttl; rp->auth = 1; } - if(rp->expire == 0){ - rp->db = 0; - dp->referenced = now-Reserved-1; - } } + l = &rp->next; + } } unlock(&dnlock);