Pārlūkot izejas kodu

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 11 gadi atpakaļ
vecāks
revīzija
4580feac51
1 mainītis faili ar 1 papildinājumiem un 0 dzēšanām
  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
 		}