Skip to content

Commit 27b1947

Browse files
committed
dnsx/alg: m fix build
1 parent 9c48d83 commit 27b1947

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

intra/dnsx/alg.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,15 @@ func (a expaddr) after(b expaddr) bool {
144144
return a.ttl.After(b.ttl)
145145
}
146146

147-
func (a expaddr) get(s xaddrstatus) []netip.Addr {
147+
func (a expaddr) get(s xaddrstatus) (out []netip.Addr) {
148148
if a.ips == nil {
149-
return nil
149+
return
150150
}
151-
if s == xalive && !a.fresh() {
152-
return nil
151+
_, fresh := a.fresh()
152+
if s == xalive && fresh {
153+
return a.ips
153154
}
154-
return a.ips
155+
return
155156
}
156157

157158
type xips struct {
@@ -348,13 +349,17 @@ func (p *xips) rmv(tid string) (done bool) {
348349
i, j := 0, 0
349350
p.pmu.Lock()
350351
defer p.pmu.Unlock()
351-
if xaddr := p.pri[tid]; xaddr.fresh() {
352+
xaddr := p.pri[tid]
353+
if _, y := xaddr.fresh(); y {
352354
i++
353355
xaddr.ttl = time.Now() // mark as expired
354356
p.pri[tid] = xaddr
355357
}
356358
for k, v := range p.aux {
357-
if strings.HasPrefix(k, tid) && v.fresh() {
359+
if _, ok := v.fresh(); !ok {
360+
continue
361+
}
362+
if strings.HasPrefix(k, tid) {
358363
j++
359364
done = done || true
360365
v.ttl = time.Now() // mark as expired
@@ -398,8 +403,9 @@ func (p *xips) merge(q *xips) {
398403
defer q.pmu.RUnlock()
399404

400405
for qk, qv := range q.pri {
401-
if pv, ok := p.pri[qk]; !ok || !pv.fresh() {
402-
p.pri[qk] = qv // copy v from q
406+
pv := p.pri[qk]
407+
if _, y := pv.fresh(); !y {
408+
p.pri[qk] = qv // copy v from q into p
403409
} else {
404410
ips := copyUniq(pv.alive(), qv.alive())
405411
ttl := pv.ttl
@@ -416,8 +422,9 @@ func (p *xips) merge(q *xips) {
416422
}
417423

418424
for qk, qv := range q.aux {
419-
if pv, ok := p.aux[qk]; !ok || !pv.fresh() {
420-
p.pri[qk] = qv
425+
pv := p.aux[qk]
426+
if _, y := pv.fresh(); !y {
427+
p.pri[qk] = qv // copy v from q into p
421428
} else {
422429
ips := copyUniq(pv.alive(), qv.alive())
423430
ttl := pv.ttl

0 commit comments

Comments
 (0)