Bläddra i källkod

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 år sedan
förälder
incheckning
4580feac51
1 ändrade filer med 1 tillägg och 0 borttagningar
  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
 		}