From 5528abc79588d15aa795a6e9b0050ff3e7616ed2 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 17 Apr 2015 03:52:54 +0200 Subject: p2p: fix the dial timer The dial timer was not reset properly when the peer count reached MaxPeers. --- p2p/server.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'p2p') diff --git a/p2p/server.go b/p2p/server.go index eaffc9d13..b5c4a1f59 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -359,9 +359,11 @@ func (srv *Server) dialLoop() { rand.Read(target[:]) findresults <- srv.ntab.Lookup(target) }() - refresh.Stop() + } else { + // Make sure we check again if the peer count falls + // below MaxPeers. + refresh.Reset(refreshPeersInterval) } - case dest := <-srv.peerConnect: dial(dest) case dests := <-findresults: @@ -371,7 +373,10 @@ func (srv *Server) dialLoop() { refresh.Reset(refreshPeersInterval) case dest := <-dialed: delete(dialing, dest.ID) - + if len(dialing) == 0 { + // Check again immediately after dialing all current candidates. + refresh.Reset(0) + } case <-srv.quit: // TODO: maybe wait for active dials return -- cgit