Преглед изворни кода

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
 		}