Skip to content

Commit

Permalink
don't backoff dialing when the context is canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Oct 18, 2017
1 parent 0ee04d7 commit 43f3370
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions p2p/net/swarm/swarm_dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ func (s *Swarm) doDial(ctx context.Context, p peer.ID) (*Conn, error) {
cancel()
log.Debugf("dial end %s", conn)
if err != nil {
log.Event(ctx, "swarmDialBackoffAdd", logdial)
s.backf.AddBackoff(p) // let others know to backoff
if err != context.Canceled {
log.Event(ctx, "swarmDialBackoffAdd", logdial)
s.backf.AddBackoff(p) // let others know to backoff
}

// ok, we failed. try again. (if loop is done, our error is output)
return nil, fmt.Errorf("dial attempt failed: %s", err)
Expand Down

0 comments on commit 43f3370

Please sign in to comment.