Fix reference counting when expiring peers.

This commit is contained in:
Owain G. Ainsworth 2013-10-14 21:56:23 +01:00
parent 340e8b999e
commit 3afdc43e69

View file

@ -261,9 +261,9 @@ func (a *AddrManager) expireNew(bucket int) {
if bad(v) {
log.Tracef("AMGR: expiring bad address %v", k)
delete(a.addrNew[bucket], k)
a.nNew--
v.refs--
if v.refs == 0 {
a.nNew--
delete(a.addrIndex, k)
}
return
@ -280,9 +280,9 @@ func (a *AddrManager) expireNew(bucket int) {
log.Tracef("AMGR: expiring oldest address %v", key)
delete(a.addrNew[bucket], key)
a.nNew--
oldest.refs--
if oldest.refs == 0 {
a.nNew--
delete(a.addrIndex, key)
}
}