Skip to content

Commit 5528abc

Browse files
committed
p2p: fix the dial timer
The dial timer was not reset properly when the peer count reached MaxPeers.
1 parent 545ff1e commit 5528abc

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎p2p/server.go‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,11 @@ func (srv *Server) dialLoop() {
359359
rand.Read(target[:])
360360
findresults <- srv.ntab.Lookup(target)
361361
}()
362-
refresh.Stop()
362+
} else {
363+
// Make sure we check again if the peer count falls
364+
// below MaxPeers.
365+
refresh.Reset(refreshPeersInterval)
363366
}
364-
365367
case dest := <-srv.peerConnect:
366368
dial(dest)
367369
case dests := <-findresults:
@@ -371,7 +373,10 @@ func (srv *Server) dialLoop() {
371373
refresh.Reset(refreshPeersInterval)
372374
case dest := <-dialed:
373375
delete(dialing, dest.ID)
374-
376+
if len(dialing) == 0 {
377+
// Check again immediately after dialing all current candidates.
378+
refresh.Reset(0)
379+
}
375380
case <-srv.quit:
376381
// TODO: maybe wait for active dials
377382
return

0 commit comments

Comments
 (0)