Skip to content

Commit

Permalink
swarm: Check context once more before dialing (#2139)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Feb 24, 2023
1 parent 9712390 commit e3a16dd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions p2p/net/swarm/swarm_dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ func (s *Swarm) dialAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr) (tra
if s.local == p {
return nil, ErrDialToSelf
}
// Check before we start work
if err := ctx.Err(); err != nil {
log.Debugf("%s swarm not dialing. Context cancelled: %v. %s %s", s.local, err, p, addr)
return nil, err
}
log.Debugf("%s swarm dialing %s %s", s.local, p, addr)

tpt := s.TransportForDialing(addr)
Expand Down

0 comments on commit e3a16dd

Please sign in to comment.