Skip to content

Commit

Permalink
Merge pull request #19 from projectmemetic/master
Browse files Browse the repository at this point in the history
CPU pegging tweaks in socket and message handling
  • Loading branch information
kekdaq authored Jul 24, 2017
2 parents c5d5b68 + 34eb252 commit 854a01b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 2
#define CLIENT_VERSION_MINOR 4
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 2

// Set to true for release, false for prerelease or test build
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3946,6 +3946,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// disconnect from peers older than this proto version
LogPrintf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString(), pfrom->nVersion);
pfrom->fDisconnect = true;
pfrom->Misbehaving(100); // just ban them
return false;
}

Expand Down
28 changes: 13 additions & 15 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ void ThreadSocketHandler()
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
MilliSleep(200); // niceness
}
}

Expand Down Expand Up @@ -1425,7 +1426,13 @@ void ThreadMessageHandler()

vector<CNode*> vNodesCopy;
{
LOCK(cs_vNodes);
// niceness, try to get a lock if not wait and try again instead of blocking
TRY_LOCK(cs_vNodes, lockNodes);
if(!lockNodes)
{
MilliSleep(100);
continue;
}
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy) {
pnode->AddRef();
Expand Down Expand Up @@ -1454,16 +1461,7 @@ void ThreadMessageHandler()
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
if (lockRecv)
{
if (!g_signals.ProcessMessages(pnode))
pnode->CloseSocketDisconnect();

if (pnode->nSendSize < SendBufferSize())
{
if (!pnode->vRecvGetData.empty() || (!pnode->vRecvMsg.empty() && pnode->vRecvMsg[0].complete()))
{
fSleep = false;
}
}
ProcessMessages(pnode);
}
}
boost::this_thread::interruption_point();
Expand All @@ -1472,7 +1470,7 @@ void ThreadMessageHandler()
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
g_signals.SendMessages(pnode, pnode == pnodeTrickle);
SendMessages(pnode, pnode == pnodeTrickle);
}
boost::this_thread::interruption_point();
}
Expand All @@ -1483,8 +1481,8 @@ void ThreadMessageHandler()
pnode->Release();
}

if (fSleep)
MilliSleep(100);
// niceness
MilliSleep(200);
}
}

Expand Down Expand Up @@ -1971,4 +1969,4 @@ bool CAddrDB::Read(CAddrMan& addr)
}

return true;
}
}
2 changes: 1 addition & 1 deletion src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Name of client reported in the 'version' message. Report the same name
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
// target servers or GUI users specifically.
const std::string CLIENT_NAME("PepeCoin-2.4.2.2");
const std::string CLIENT_NAME("PepeCoin-2.4.3.2");

// Client version number
#define CLIENT_VERSION_SUFFIX "-KekdaqMT"
Expand Down

0 comments on commit 854a01b

Please sign in to comment.