mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
connmgr: Check for canceled connection before connect
This is a port of btcd commit 9bfb2ca0346b57e246cc96fa31074df521175240. This will ensure cancelation is reliable for all cases.
This commit is contained in:
parent
79d444257f
commit
5048959fdc
@ -409,6 +409,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))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user