From 576ba8868b7cd87e448f4591fb543cb1fa870740 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 15 Jan 2016 19:12:09 +0200 Subject: [PATCH] Return immediately on ErrDialTimeout when dialing HostClient hosts --- client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client.go b/client.go index 884f9c5..9d50924 100644 --- a/client.go +++ b/client.go @@ -1089,6 +1089,12 @@ func (c *HostClient) dialHostHard() (conn net.Conn, err error) { if err == nil { return conn, nil } + if err == ErrDialTimeout { + // The function already has been blocked for DefaultDialTimeout, + // so let's return the error to the caller instead of waiting + // for unspecified time during dialing the remaining hosts. + return nil, err + } n-- } return nil, err