Skip to content

Commit

Permalink
add timeouts for dial requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Reid committed Jan 26, 2018
1 parent e06f2d8 commit e8fe902
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion netutil/multidialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ func (m *MultiDialer) DialContext(ctx context.Context, network, ignoredAddress s
return nil, ctx.Err()

default:
conn, err := m.Dialer.DialContext(ctx, network, addr)
// Create new child context for a single dial
dctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()

conn, err := m.Dialer.DialContext(dctx, network, addr)
if err != nil {
continue
}
Expand Down

0 comments on commit e8fe902

Please sign in to comment.