From 3d4405e87b10d073af2b2ed6d9e3016ebc000781 Mon Sep 17 00:00:00 2001 From: Lyndsay Roger Date: Sun, 16 Aug 2015 14:01:47 +1200 Subject: [PATCH] Improve purging of remote clients we can not connect to --- dnsseeder.go | 10 +++++++++- main.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) 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: