|
|
@ -89,7 +89,6 @@ std::string strSubVersion; |
|
|
|
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ); |
|
|
|
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ); |
|
|
|
|
|
|
|
|
|
|
|
static CSemaphore *semOutbound = NULL; |
|
|
|
static CSemaphore *semOutbound = NULL; |
|
|
|
boost::condition_variable messageHandlerCondition; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Signals for message handling
|
|
|
|
// Signals for message handling
|
|
|
|
static CNodeSignals g_signals; |
|
|
|
static CNodeSignals g_signals; |
|
|
@ -688,8 +687,9 @@ void CNode::copyStats(CNodeStats &stats) |
|
|
|
#undef X |
|
|
|
#undef X |
|
|
|
|
|
|
|
|
|
|
|
// requires LOCK(cs_vRecvMsg)
|
|
|
|
// requires LOCK(cs_vRecvMsg)
|
|
|
|
bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) |
|
|
|
bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
complete = false; |
|
|
|
while (nBytes > 0) { |
|
|
|
while (nBytes > 0) { |
|
|
|
|
|
|
|
|
|
|
|
// get current incomplete message, or create a new one
|
|
|
|
// get current incomplete message, or create a new one
|
|
|
@ -728,7 +728,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) |
|
|
|
i->second += msg.hdr.nMessageSize + CMessageHeader::HEADER_SIZE; |
|
|
|
i->second += msg.hdr.nMessageSize + CMessageHeader::HEADER_SIZE; |
|
|
|
|
|
|
|
|
|
|
|
msg.nTime = GetTimeMicros(); |
|
|
|
msg.nTime = GetTimeMicros(); |
|
|
|
messageHandlerCondition.notify_one(); |
|
|
|
complete = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1247,8 +1247,11 @@ void CConnman::ThreadSocketHandler() |
|
|
|
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); |
|
|
|
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); |
|
|
|
if (nBytes > 0) |
|
|
|
if (nBytes > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) |
|
|
|
bool notify = false; |
|
|
|
|
|
|
|
if (!pnode->ReceiveMsgBytes(pchBuf, nBytes, notify)) |
|
|
|
pnode->CloseSocketDisconnect(); |
|
|
|
pnode->CloseSocketDisconnect(); |
|
|
|
|
|
|
|
if(notify) |
|
|
|
|
|
|
|
messageHandlerCondition.notify_one(); |
|
|
|
pnode->nLastRecv = GetTime(); |
|
|
|
pnode->nLastRecv = GetTime(); |
|
|
|
pnode->nRecvBytes += nBytes; |
|
|
|
pnode->nRecvBytes += nBytes; |
|
|
|
pnode->RecordBytesRecv(nBytes); |
|
|
|
pnode->RecordBytesRecv(nBytes); |
|
|
|