From e3b56f76413b39655b6c52d339bfb3b07a388d06 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Tue, 7 Aug 2018 16:48:32 +0300 Subject: [PATCH] pubsub: fix ping logic --- pubsub.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubsub.go b/pubsub.go index 5e2a863..e3c6338 100644 --- a/pubsub.go +++ b/pubsub.go @@ -435,7 +435,7 @@ func (c *PubSub) initChannel() { timer := time.NewTimer(timeout) timer.Stop() - var healthy bool + healthy := true var pingErr error for { timer.Reset(timeout) @@ -446,9 +446,9 @@ func (c *PubSub) initChannel() { <-timer.C } case <-timer.C: + pingErr = c.Ping() if healthy { healthy = false - pingErr = c.Ping() } else { c.mu.Lock() c._reconnect(pingErr)