Skip to content

Commit

Permalink
Merge pull request #38 from libp2p/fix/libp2p/go-libp2p-kad-dht/96
Browse files Browse the repository at this point in the history
don't backoff dialing when the context is canceled
  • Loading branch information
Stebalien authored Oct 18, 2017
2 parents 0ee04d7 + 43f3370 commit 6b32365
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 6b32365

Please sign in to comment.