diff --git a/src/net.cpp b/src/net.cpp index 6b8c459e..c1bf5d23 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1519,9 +1519,15 @@ void ThreadMessageHandler(int ncore) if (pnode == pnodeSync) fHaveSyncNode = true; } + + // check if one of the other threads has the sync node + BOOST_FOREACH(CNode* pnode, vNodesFullSet) { + if(pnode == pnodeSync) + fHaveSyncNode = true; + } } - if (!fHaveSyncNode) + if (!fHaveSyncNode && IsSyncing()) // Only call this if IsSyncing is true StartSync(vNodesCopy); // Poll the connected nodes for messages diff --git a/src/net.h b/src/net.h index b6ceca7e..4028e658 100644 --- a/src/net.h +++ b/src/net.h @@ -533,9 +533,11 @@ class CNode ssSend.GetAndClear(*it); nSendSize += (*it).size(); + // Don't attempt optimistic write here, because this may be called from one of the + // message handling threads. Leave it to be processed by the socket handling thread and avoid potential lock train. // If write queue empty, attempt "optimistic write" - if (it == vSendMsg.begin()) - SocketSendData(this); + //if (it == vSendMsg.begin()) + // SocketSendData(this); LEAVE_CRITICAL_SECTION(cs_vSend); }