@@ -693,7 +693,6 @@ void CNode::copyStats(CNodeStats& stats)
693693}
694694#undef X
695695
696- // requires LOCK(cs_vRecvMsg)
697696bool CNode::ReceiveMsgBytes (const char * pch, unsigned int nBytes, bool & complete)
698697{
699698 complete = false ;
@@ -1086,12 +1085,9 @@ void CConnman::ThreadSocketHandler()
10861085 {
10871086 TRY_LOCK (pnode->cs_vSend , lockSend);
10881087 if (lockSend) {
1089- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1090- if (lockRecv) {
10911088 TRY_LOCK (pnode->cs_inventory , lockInv);
10921089 if (lockInv)
10931090 fDelete = true ;
1094- }
10951091 }
10961092 }
10971093 if (fDelete ) {
@@ -1149,15 +1145,10 @@ void CConnman::ThreadSocketHandler()
11491145 // write buffer in this case before receiving more. This avoids
11501146 // needlessly queueing received data, if the remote peer is not themselves
11511147 // receiving data. This means properly utilizing TCP flow control signalling.
1152- // * Otherwise, if there is no (complete) message in the receive buffer,
1153- // or there is space left in the buffer, select() for receiving data.
1154- // * (if neither of the above applies, there is certainly one message
1155- // in the receiver buffer ready to be processed).
1156- // Together, that means that at least one of the following is always possible,
1157- // so we don't deadlock:
1158- // * We send some data.
1159- // * We wait for data to be received (and disconnect after timeout).
1160- // * We process a message in the buffer (message handler thread).
1148+ // * Otherwise, if there is space left in the receive buffer, select() for
1149+ // receiving data.
1150+ // * Hand off all complete messages to the processor, to be handled without
1151+ // blocking here.
11611152 {
11621153 LOCK (pnode->cs_vSend );
11631154 if (!pnode->vSendMsg .empty ()) {
@@ -1166,8 +1157,7 @@ void CConnman::ThreadSocketHandler()
11661157 }
11671158 }
11681159 {
1169- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1170- if (lockRecv && !pnode->fPauseRecv )
1160+ if (!pnode->fPauseRecv )
11711161 FD_SET (pnode->hSocket , &fdsetRecv);
11721162 }
11731163 }
@@ -1220,8 +1210,7 @@ void CConnman::ThreadSocketHandler()
12201210 if (pnode->hSocket == INVALID_SOCKET)
12211211 continue ;
12221212 if (FD_ISSET (pnode->hSocket , &fdsetRecv) || FD_ISSET (pnode->hSocket , &fdsetError)) {
1223- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1224- if (lockRecv) {
1213+ {
12251214 {
12261215 // typical socket buffer is 8K-64K
12271216 char pchBuf[0x10000 ];
@@ -1807,13 +1796,8 @@ void CConnman::ThreadMessageHandler()
18071796 continue ;
18081797
18091798 // Receive messages
1810- {
1811- TRY_LOCK (pnode->cs_vRecvMsg , lockRecv);
1812- if (lockRecv) {
1813- bool fMoreNodeWork = GetNodeSignals ().ProcessMessages (pnode, *this , flagInterruptMsgProc);
1814- fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend );
1815- }
1816- }
1799+ bool fMoreNodeWork = GetNodeSignals ().ProcessMessages (pnode, *this , flagInterruptMsgProc);
1800+ fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend );
18171801 if (flagInterruptMsgProc)
18181802 return ;
18191803
0 commit comments