From e89b12d0c543a383cb760cc8cbb26aa785d1422b Mon Sep 17 00:00:00 2001 From: TheLazieR Yip Date: Thu, 16 Feb 2017 22:40:40 +0700 Subject: [PATCH] Gracefully not accept incoming connection (#1342) --- src/net.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 8b895df1a..b53787e65 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -963,12 +963,6 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) { } static void AcceptConnection(const ListenSocket& hListenSocket) { - // don't accept incoming connections until fully synced - if(fMasterNode && !masternodeSync.IsSynced()) { - LogPrintf("AcceptConnection -- masternode is not synced yet, skipping inbound connection attempt\n"); - return; - } - struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len); @@ -1029,6 +1023,13 @@ static void AcceptConnection(const ListenSocket& hListenSocket) { } } + // don't accept incoming connections until fully synced + if(fMasterNode && !masternodeSync.IsSynced()) { + LogPrintf("AcceptConnection -- masternode is not synced yet, skipping inbound connection attempt\n"); + CloseSocket(hSocket); + return; + } + CNode* pnode = new CNode(hSocket, addr, "", true); pnode->fWhitelisted = whitelisted;