From 9bfb2ca0346b57e246cc96fa31074df521175240 Mon Sep 17 00:00:00 2001 From: Roei Erez Date: Wed, 10 Apr 2019 05:54:18 +0300 Subject: [PATCH] connmgr: check for canceled connection before connect This will ensure cancelation is reliable for all cases. --- connmgr/connmanager.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/connmgr/connmanager.go b/connmgr/connmanager.go index 2116934a..9a681902 100644 --- a/connmgr/connmanager.go +++ b/connmgr/connmanager.go @@ -408,6 +408,14 @@ func (cm *ConnManager) Connect(c *ConnReq) { if atomic.LoadInt32(&cm.stop) != 0 { return } + + // During the time we wait for retry there is a chance that + // this connection was already cancelled + if c.State() == ConnCanceled { + log.Debugf("Ignoring connect for canceled connreq=%v", c) + return + } + if atomic.LoadUint64(&c.id) == 0 { atomic.StoreUint64(&c.id, atomic.AddUint64(&cm.connReqCount, 1))