Gracefully not accept incoming connection (#1342)

This commit is contained in:
TheLazieR Yip 2017-02-16 22:40:40 +07:00 committed by UdjinM6
parent 80b71d9746
commit e89b12d0c5

View File

@ -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;