diff --git a/dnsseeder.go b/dnsseeder.go index 3b71f5e..682aeb5 100644 --- a/dnsseeder.go +++ b/dnsseeder.go @@ -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() { 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) + } } diff --git a/main.go b/main.go index 4c2cd17..fd21791 100644 --- a/main.go +++ b/main.go @@ -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: