Skip to content

Commit

Permalink
Merge pull request redis#798 from josh-tepper/tls-respects-dial-timeout
Browse files Browse the repository at this point in the history
Establishing TLS connections respect DialTimeout
  • Loading branch information
vmihailenco authored Jun 29, 2018
2 parents 8a90ef6 + 8c513f1 commit d409b91
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ func (opt *Options) init() {
}
if opt.Dialer == nil {
opt.Dialer = func() (net.Conn, error) {
conn, err := net.DialTimeout(opt.Network, opt.Addr, opt.DialTimeout)
if opt.TLSConfig == nil || err != nil {
return conn, err
netDialer := &net.Dialer{Timeout: opt.DialTimeout}
if opt.TLSConfig == nil {
return netDialer.Dial(opt.Network, opt.Addr)
} else {
return tls.DialWithDialer(netDialer, opt.Network, opt.Addr, opt.TLSConfig)
}
t := tls.Client(conn, opt.TLSConfig)
return t, t.Handshake()
}
}
if opt.PoolSize == 0 {
Expand Down

0 comments on commit d409b91

Please sign in to comment.