From c8f35aea45af5d473e9b15349fc6552bcf9dda8b Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 2 Oct 2014 10:26:25 -0700 Subject: [PATCH] consul: don't close a nil connection --- consul/pool.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/consul/pool.go b/consul/pool.go index 3b7e80c297..84214d2a46 100644 --- a/consul/pool.go +++ b/consul/pool.go @@ -4,15 +4,16 @@ import ( "container/list" "crypto/tls" "fmt" - "github.com/hashicorp/yamux" - "github.com/inconshreveable/muxado" - "github.com/ugorji/go/codec" "io" "net" "net/rpc" "sync" "sync/atomic" "time" + + "github.com/hashicorp/yamux" + "github.com/inconshreveable/muxado" + "github.com/ugorji/go/codec" ) // msgpackHandle is a shared handle for encoding/decoding of RPC messages @@ -221,11 +222,12 @@ func (p *ConnPool) getNewConn(addr net.Addr, version int) (*Conn, error) { } // Wrap the connection in a TLS client - conn, err = wrapTLSClient(conn, p.tlsConfig) + tlsConn, err := wrapTLSClient(conn, p.tlsConfig) if err != nil { conn.Close() return nil, err } + conn = tlsConn } // Switch the multiplexing based on version