Browse Source

Improve purging of remote clients we can not connect to

master
Lyndsay Roger 9 years ago
parent
commit
3d4405e87b
  1. 10
      dnsseeder.go
  2. 2
      main.go

10
dnsseeder.go

@ -265,6 +265,9 @@ func crc16(bs []byte) uint16 { @@ -265,6 +265,9 @@ func crc16(bs []byte) uint16 {
}
func (s *Seeder) purgeNG() {
c := 0
s.mtx.Lock()
defer s.mtx.Unlock()
@ -276,13 +279,18 @@ func (s *Seeder) purgeNG() { @@ -276,13 +279,18 @@ func (s *Seeder) purgeNG() {
if config.verbose {
log.Printf("status - purging twistee %s after %v failed connections\n", k, tw.connectFails)
}
c++
// remove the map entry and mark the old twistee as
// nil so garbage collector will remove it
s.theList[k] = nil
delete(s.theList, k)
tw = nil
}
}
if config.verbose {
log.Printf("status - purging complete. %v twistees purged\n", c)
}
}

2
main.go

@ -81,7 +81,7 @@ func main() { @@ -81,7 +81,7 @@ func main() {
dowhile = false
case <-purgeChan:
if config.debug {
log.Printf("debug - clean old statusNG twistees timer triggered\n")
log.Printf("debug - purge old statusNG twistees timer triggered\n")
}
config.seeder.purgeNG()
case <-dnsChan:

Loading…
Cancel
Save