Skip to content

Commit

Permalink
Deadlock fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SDCDev committed May 11, 2015
1 parent 5b95332 commit 08b089c
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 110 deletions.
2 changes: 1 addition & 1 deletion shadow.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = shadow
VERSION = 1.3.2.3
VERSION = 1.3.2.4
INCLUDEPATH += src src/json src/qt
DEFINES += BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 3
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 3
#define CLIENT_VERSION_BUILD 4

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
Expand Down
29 changes: 13 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6166,7 +6166,7 @@ bool ProcessMessages(CNode* pfrom)
}


bool SendMessages(CNode* pto, bool fSendTrickle)
bool SendMessages(CNode* pto, std::vector<CNode*> &vNodesCopy, bool fSendTrickle)
{
// Don't send anything until we get their version message
if (pto->nVersion == 0)
Expand Down Expand Up @@ -6214,23 +6214,20 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
static int64_t nLastRebroadcast;
if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
{
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
// Periodically clear setAddrKnown to allow refresh broadcasts
if (nLastRebroadcast)
pnode->setAddrKnown.clear();
// Periodically clear setAddrKnown to allow refresh broadcasts
if (nLastRebroadcast)
pnode->setAddrKnown.clear();

// Rebroadcast our address
if (!fNoListen)
{
CAddress addr = GetLocalAddress(&pnode->addr);
if (addr.IsRoutable())
pnode->PushAddress(addr);
};
// Rebroadcast our address
if (!fNoListen)
{
CAddress addr = GetLocalAddress(&pnode->addr);
if (addr.IsRoutable())
pnode->PushAddress(addr);
};
}
};
nLastRebroadcast = GetTime();
};

Expand Down Expand Up @@ -6268,7 +6265,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
std::vector<CInv> vInvWait;

{
LOCK(pto->cs_inventory);
LOCK2(pwalletMain->cs_wallet, pto->cs_inventory);
vInv.reserve(pto->vInventoryToSend.size());
vInvWait.reserve(pto->vInventoryToSend.size());
BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend)
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void PrintBlockTree();
CBlockIndex* FindBlockByHeight(int nHeight);
CBlockThinIndex* FindBlockThinByHeight(int nHeight);
bool ProcessMessages(CNode* pfrom);
bool SendMessages(CNode* pto, bool fSendTrickle);
bool SendMessages(CNode* pto, std::vector<CNode*> &vNodesCopy, bool fSendTrickle);

bool LoadExternalBlockFile(int nFile, FILE* fileIn);

Expand Down
4 changes: 2 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ void ThreadMessageHandler()
for (;;)
{
boost::this_thread::interruption_point();
vector<CNode*> vNodesCopy;
std::vector<CNode*> vNodesCopy;
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
Expand Down Expand Up @@ -1559,7 +1559,7 @@ void ThreadMessageHandler()
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
SendMessages(pnode, pnode == pnodeTrickle);
SendMessages(pnode, vNodesCopy, pnode == pnodeTrickle);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class SecMsgNode

~SecMsgNode() {};

CCriticalSection cs_smsg_net;
int64_t lastSeen;
int64_t lastMatched;
int64_t ignoreUntil;
Expand Down

0 comments on commit 08b089c

Please sign in to comment.