@@ -644,7 +644,6 @@ void CNode::copyStats(CNodeStats &stats)
644
644
}
645
645
#undef X
646
646
647
- // requires LOCK(cs_vRecvMsg)
648
647
bool CNode::ReceiveMsgBytes (const char *pch, unsigned int nBytes, bool & complete)
649
648
{
650
649
complete = false ;
@@ -1080,13 +1079,9 @@ void CConnman::ThreadSocketHandler()
1080
1079
TRY_LOCK (pnode->cs_vSend , lockSend);
1081
1080
if (lockSend)
1082
1081
{
1083
- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1084
- if (lockRecv)
1085
- {
1086
1082
TRY_LOCK (pnode->cs_inventory , lockInv);
1087
1083
if (lockInv)
1088
1084
fDelete = true ;
1089
- }
1090
1085
}
1091
1086
}
1092
1087
if (fDelete )
@@ -1146,15 +1141,10 @@ void CConnman::ThreadSocketHandler()
1146
1141
// write buffer in this case before receiving more. This avoids
1147
1142
// needlessly queueing received data, if the remote peer is not themselves
1148
1143
// receiving data. This means properly utilizing TCP flow control signalling.
1149
- // * Otherwise, if there is no (complete) message in the receive buffer,
1150
- // or there is space left in the buffer, select() for receiving data.
1151
- // * (if neither of the above applies, there is certainly one message
1152
- // in the receiver buffer ready to be processed).
1153
- // Together, that means that at least one of the following is always possible,
1154
- // so we don't deadlock:
1155
- // * We send some data.
1156
- // * We wait for data to be received (and disconnect after timeout).
1157
- // * We process a message in the buffer (message handler thread).
1144
+ // * Otherwise, if there is space left in the receive buffer, select() for
1145
+ // receiving data.
1146
+ // * Hand off all complete messages to the processor, to be handled without
1147
+ // blocking here.
1158
1148
{
1159
1149
TRY_LOCK (pnode->cs_vSend , lockSend);
1160
1150
if (lockSend) {
@@ -1165,8 +1155,7 @@ void CConnman::ThreadSocketHandler()
1165
1155
}
1166
1156
}
1167
1157
{
1168
- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1169
- if (lockRecv && !pnode->fPauseRecv )
1158
+ if (!pnode->fPauseRecv )
1170
1159
FD_SET (pnode->hSocket , &fdsetRecv);
1171
1160
}
1172
1161
}
@@ -1225,8 +1214,6 @@ void CConnman::ThreadSocketHandler()
1225
1214
continue ;
1226
1215
if (FD_ISSET (pnode->hSocket , &fdsetRecv) || FD_ISSET (pnode->hSocket , &fdsetError))
1227
1216
{
1228
- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1229
- if (lockRecv)
1230
1217
{
1231
1218
{
1232
1219
// typical socket buffer is 8K-64K
@@ -1865,14 +1852,8 @@ void CConnman::ThreadMessageHandler()
1865
1852
continue ;
1866
1853
1867
1854
// Receive messages
1868
- {
1869
- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1870
- if (lockRecv)
1871
- {
1872
- bool fMoreNodeWork = GetNodeSignals ().ProcessMessages (pnode, *this , flagInterruptMsgProc);
1873
- fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend );
1874
- }
1875
- }
1855
+ bool fMoreNodeWork = GetNodeSignals ().ProcessMessages (pnode, *this , flagInterruptMsgProc);
1856
+ fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend );
1876
1857
if (flagInterruptMsgProc)
1877
1858
return ;
1878
1859
0 commit comments