From 0330c53fa12bce4afd01c6bda72811e17e5faf3e Mon Sep 17 00:00:00 2001 From: Lyndsay Roger Date: Tue, 18 Aug 2015 20:24:51 +1200 Subject: [PATCH] Bug fix for loop on message receive & other fixes --- crawler.go | 17 +++++++++++------ dnsseeder.go | 1 - server.go | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crawler.go b/crawler.go index 980baf8..bc01c76 100644 --- a/crawler.go +++ b/crawler.go @@ -14,6 +14,11 @@ import ( // list of currently active addresses func crawlTwistee(tw *Twistee) { + tw.crawlActive = true + tw.crawlStart = time.Now() + + defer crawlEnd(tw) + if config.debug { log.Printf("status - start crawl: twistee %s status: %v:%v lastcrawl: %s\n", net.JoinHostPort(tw.na.IP.String(), @@ -23,11 +28,6 @@ func crawlTwistee(tw *Twistee) { time.Since(tw.crawlStart).String()) } - tw.crawlActive = true - tw.crawlStart = time.Now() - - defer crawlEnd(tw) - // connect to the remote ip and ask them for their addr list ras, err := crawlIP(tw) if err != nil { @@ -202,6 +202,7 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, error) { return nil, err } + c := 0 dowhile := true for dowhile == true { @@ -224,10 +225,14 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, error) { } } } + // if we get more than 25 messages before the addr we asked for then give up on this client + if c++; c >= 25 { + dowhile = false + } } // should never get here but need a return command - return nil, nil + return nil, errors.New("FIXME - something went wrong and did not get an Addr response") } /* diff --git a/dnsseeder.go b/dnsseeder.go index 833feac..169c9b9 100644 --- a/dnsseeder.go +++ b/dnsseeder.go @@ -150,7 +150,6 @@ func (s *Seeder) startCrawlers() { } // all looks go so start a go routine to crawl the remote twistee - tw.crawlActive = true go crawlTwistee(tw) c.started++ } diff --git a/server.go b/server.go index c264d20..8187f82 100644 --- a/server.go +++ b/server.go @@ -40,7 +40,7 @@ func updateDNS(s *Seeder) { for _, tw := range s.theList { // when we reach max exit - if numRR >= 15 { + if numRR >= 25 { break }