@ -761,7 +761,7 @@ const uint256& CNetMessage::GetMessageHash() const
// requires LOCK(cs_vSend)
// requires LOCK(cs_vSend)
size_t SocketSendData ( CNode * pnode )
size_t CConnman : : SocketSendData ( CNode * pnode )
{
{
auto it = pnode - > vSendMsg . begin ( ) ;
auto it = pnode - > vSendMsg . begin ( ) ;
size_t nSentSize = 0 ;
size_t nSentSize = 0 ;
@ -778,6 +778,7 @@ size_t SocketSendData(CNode *pnode)
if ( pnode - > nSendOffset = = data . size ( ) ) {
if ( pnode - > nSendOffset = = data . size ( ) ) {
pnode - > nSendOffset = 0 ;
pnode - > nSendOffset = 0 ;
pnode - > nSendSize - = data . size ( ) ;
pnode - > nSendSize - = data . size ( ) ;
pnode - > fPauseSend = pnode - > nSendSize > nSendBufferMaxSize ;
it + + ;
it + + ;
} else {
} else {
// could not send full message; stop sending more
// could not send full message; stop sending more
@ -1286,10 +1287,11 @@ void CConnman::ThreadSocketHandler()
TRY_LOCK ( pnode - > cs_vSend , lockSend ) ;
TRY_LOCK ( pnode - > cs_vSend , lockSend ) ;
if ( lockSend ) {
if ( lockSend ) {
size_t nBytes = SocketSendData ( pnode ) ;
size_t nBytes = SocketSendData ( pnode ) ;
if ( nBytes )
if ( nBytes ) {
RecordBytesSent ( nBytes ) ;
RecordBytesSent ( nBytes ) ;
}
}
}
}
}
//
//
// Inactivity checking
// Inactivity checking
@ -1868,7 +1870,7 @@ void CConnman::ThreadMessageHandler()
if ( lockRecv )
if ( lockRecv )
{
{
bool fMoreNodeWork = GetNodeSignals ( ) . ProcessMessages ( pnode , * this , flagInterruptMsgProc ) ;
bool fMoreNodeWork = GetNodeSignals ( ) . ProcessMessages ( pnode , * this , flagInterruptMsgProc ) ;
fMoreWork | = ( fMoreNodeWork & & pnode - > nSendSize < GetSendBufferSize ( ) ) ;
fMoreWork | = ( fMoreNodeWork & & ! pnode - > fPauseSend ) ;
}
}
}
}
if ( flagInterruptMsgProc )
if ( flagInterruptMsgProc )
@ -2595,6 +2597,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
lastSentFeeFilter = 0 ;
lastSentFeeFilter = 0 ;
nextSendTimeFeeFilter = 0 ;
nextSendTimeFeeFilter = 0 ;
fPauseRecv = false ;
fPauseRecv = false ;
fPauseSend = false ;
nProcessQueueSize = 0 ;
nProcessQueueSize = 0 ;
BOOST_FOREACH ( const std : : string & msg , getAllNetMessageTypes ( ) )
BOOST_FOREACH ( const std : : string & msg , getAllNetMessageTypes ( ) )
@ -2675,6 +2678,8 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
pnode - > mapSendBytesPerMsgCmd [ msg . command ] + = nTotalSize ;
pnode - > mapSendBytesPerMsgCmd [ msg . command ] + = nTotalSize ;
pnode - > nSendSize + = nTotalSize ;
pnode - > nSendSize + = nTotalSize ;
if ( pnode - > nSendSize > nSendBufferMaxSize )
pnode - > fPauseSend = true ;
pnode - > vSendMsg . push_back ( std : : move ( serializedHeader ) ) ;
pnode - > vSendMsg . push_back ( std : : move ( serializedHeader ) ) ;
if ( nMessageSize )
if ( nMessageSize )
pnode - > vSendMsg . push_back ( std : : move ( msg . data ) ) ;
pnode - > vSendMsg . push_back ( std : : move ( msg . data ) ) ;