From 312088b56048132d0be68ccad0b26613a25828cb Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 12 Feb 2018 15:46:38 +0300 Subject: [PATCH] Fix connectivity check in CActiveMasternode::ManageStateInitial (#1918) --- src/activemasternode.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 98b5f66d5..8bff11cce 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -6,6 +6,7 @@ #include "masternode.h" #include "masternode-sync.h" #include "masternodeman.h" +#include "netbase.h" #include "protocol.h" // Keep track of the active Masternode @@ -180,12 +181,13 @@ void CActiveMasternode::ManageStateInitial(CConnman& connman) return; } + // Check socket connectivity LogPrintf("CActiveMasternode::ManageStateInitial -- Checking inbound connection to '%s'\n", service.ToString()); + SOCKET hSocket; + bool fConnected = ConnectSocket(service, hSocket, nConnectTimeout) && IsSelectableSocket(hSocket); + CloseSocket(hSocket); - CAddress addr(service, NODE_NETWORK); - connman.OpenMasternodeConnection(addr); - - if (!connman.IsConnected(addr, CConnman::AllNodes)) { + if (!fConnected) { nState = ACTIVE_MASTERNODE_NOT_CAPABLE; strNotCapableReason = "Could not connect to " + service.ToString(); LogPrintf("CActiveMasternode::ManageStateInitial -- %s: %s\n", GetStateString(), strNotCapableReason);