don't backoff dialing when the context is canceled
fixes libp2p/go-libp2p-kad-dht#96
@@ -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 {
+ 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)
