aboutsummaryrefslogtreecommitdiff
path: root/tcpdialer.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-10-29 23:02:11 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-10-29 23:02:11 +0300
commit44f08d5588a9caf5426ec99502c15e5e4f21a628 (patch)
tree62aee43e3ce12b5d8f3f1205e9d700fdfd3063a9 /tcpdialer.go
parentProperly handle TimeoutHandler in custom server implementations, which use Re... (diff)
downloadfasthttp-44f08d5588a9caf5426ec99502c15e5e4f21a628.tar.gz
fasthttp-44f08d5588a9caf5426ec99502c15e5e4f21a628.tar.bz2
fasthttp-44f08d5588a9caf5426ec99502c15e5e4f21a628.zip
Issue #196: avoid returning (nil, nil) from fasthttp.Dial*
Diffstat (limited to 'tcpdialer.go')
-rw-r--r--tcpdialer.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/tcpdialer.go b/tcpdialer.go
index ffb37a8..e31fd75 100644
--- a/tcpdialer.go
+++ b/tcpdialer.go
@@ -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")