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 {
} }
func (s *Seeder) purgeNG() { func (s *Seeder) purgeNG() {
c := 0
s.mtx.Lock() s.mtx.Lock()
defer s.mtx.Unlock() defer s.mtx.Unlock()
@ -276,13 +279,18 @@ func (s *Seeder) purgeNG() {
if config.verbose { if config.verbose {
log.Printf("status - purging twistee %s after %v failed connections\n", k, tw.connectFails) 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 // remove the map entry and mark the old twistee as
// nil so garbage collector will remove it // nil so garbage collector will remove it
s.theList[k] = nil
delete(s.theList, k) 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() {
dowhile = false dowhile = false
case <-purgeChan: case <-purgeChan:
if config.debug { 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() config.seeder.purgeNG()
case <-dnsChan: case <-dnsChan:

Loading…
Cancel
Save