From f3352505128dc74d47476c6812e8cd7a5c7de328 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 4 May 2017 16:47:48 -0700 Subject: [PATCH] server: fix regression in handling persistent connection requesrts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a bug that was introduced when the concurrent connection handling logic was re-written: if we don’t properly add the persistent outbound connection to the persistent conn reqs map. The fix is easy: add the pending conn req to the proper map. --- server.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 7270299b..6dec4054 100644 --- a/server.go +++ b/server.go @@ -1125,10 +1125,17 @@ func (s *server) handleConnectPeer(msg *connectPeerMsg) { // persistent connection to the peer. srvrLog.Debugf("Connecting to %v", addr) if msg.persistent { - go s.connMgr.Connect(&connmgr.ConnReq{ + connReq := &connmgr.ConnReq{ Addr: addr, Permanent: true, - }) + } + + s.pendingConnMtx.Lock() + s.persistentConnReqs[targetPub] = append(s.persistentConnReqs[targetPub], + connReq) + s.pendingConnMtx.Unlock() + + go s.connMgr.Connect(connReq) msg.err <- nil } else { // If we're not making a persistent connection, then we'll