瀏覽代碼

Fix potential case of non-nil conn being returned with an error

Some versions of go returned a non-nil interface containing nil, which when
compared directly with nil would fail. Work around that.
Evan Huus 10 年之前
父節點
當前提交
4580feac51
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      broker.go

+ 1 - 0
broker.go

@@ -100,6 +100,7 @@ func (b *Broker) Open(conf *BrokerConfig) error {
 
 		b.conn, b.connErr = net.DialTimeout("tcp", b.addr, conf.DialTimeout)
 		if b.connErr != nil {
+			b.conn = nil
 			Logger.Printf("Failed to connect to broker %s: %s\n", b.addr, b.connErr)
 			return
 		}