Skip to content

Commit 82cd507

Browse files
committed
must fixed reconnect issue this time
1 parent 9b5e181 commit 82cd507

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cluster.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func (cr *Cluster) Enable(ctx context.Context) (err error) {
359359
if !ok {
360360
if keepaliveCtx.Err() == nil {
361361
logInfo("Reconnecting due to keepalive failed")
362-
cr.Disable(ctx)
362+
cr.disable(ctx)
363363
logInfo("Reconnecting ...")
364364
if !cr.Connect(ctx) {
365365
logError("Cannot reconnect to server, exit.")
@@ -422,11 +422,14 @@ func (cr *Cluster) disconnected() bool {
422422
}
423423

424424
func (cr *Cluster) Disable(ctx context.Context) (ok bool) {
425+
cr.shouldEnable.Store(false)
426+
return cr.disable(ctx)
427+
}
428+
429+
func (cr *Cluster) disable(ctx context.Context) (ok bool) {
425430
cr.mux.Lock()
426431
defer cr.mux.Unlock()
427432

428-
cr.shouldEnable.Store(false)
429-
430433
if !cr.enabled.Load() {
431434
logDebug("Extra disable")
432435
return false

0 commit comments

Comments
 (0)