Permalink
Browse files

Issue #196: avoid returning (nil, nil) from fasthttp.Dial*

  • Loading branch information...
valyala committed Oct 29, 2016
1 parent cd7c1da commit 44f08d5588a9caf5426ec99502c15e5e4f21a628
Showing with 6 additions and 4 deletions.
  1. +6 −4 tcpdialer.go
View
@@ -329,10 +329,7 @@ func (d *tcpDialer) getTCPAddrs(addr string) ([]net.TCPAddr, uint32, error) {
d.tcpAddrsLock.Unlock()
}
idx := uint32(0)
if len(e.addrs) > 0 {
idx = atomic.AddUint32(&e.addrsIdx, 1)
}
idx := atomic.AddUint32(&e.addrsIdx, 1)
return e.addrs, idx, nil
}
@@ -363,5 +360,10 @@ func resolveTCPAddrs(addr string, dualStack bool) ([]net.TCPAddr, error) {
Port: port,
})
}
if len(addrs) == 0 {
return nil, errNoDNSEntries
}
return addrs, nil
}
var errNoDNSEntries = errors.New("couldn't find DNS entries for the given domain. Try using DialDualStack")

0 comments on commit 44f08d5

Please sign in to comment.