|
|
@ -1152,9 +1152,6 @@ void CConnman::ThreadSocketHandler() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pnode->hSocket == INVALID_SOCKET) |
|
|
|
if (pnode->hSocket == INVALID_SOCKET) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
FD_SET(pnode->hSocket, &fdsetError); |
|
|
|
|
|
|
|
hSocketMax = std::max(hSocketMax, pnode->hSocket); |
|
|
|
|
|
|
|
have_fds = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Implement the following logic:
|
|
|
|
// Implement the following logic:
|
|
|
|
// * If there is data to send, select() for sending data. As this only
|
|
|
|
// * If there is data to send, select() for sending data. As this only
|
|
|
@ -1166,15 +1163,23 @@ void CConnman::ThreadSocketHandler() |
|
|
|
// receiving data.
|
|
|
|
// receiving data.
|
|
|
|
// * Hand off all complete messages to the processor, to be handled without
|
|
|
|
// * Hand off all complete messages to the processor, to be handled without
|
|
|
|
// blocking here.
|
|
|
|
// blocking here.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool select_recv = !pnode->fPauseRecv; |
|
|
|
|
|
|
|
bool select_send; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(pnode->cs_vSend); |
|
|
|
LOCK(pnode->cs_vSend); |
|
|
|
if (!pnode->vSendMsg.empty()) { |
|
|
|
select_send = !pnode->vSendMsg.empty(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FD_SET(pnode->hSocket, &fdsetError); |
|
|
|
|
|
|
|
hSocketMax = std::max(hSocketMax, pnode->hSocket); |
|
|
|
|
|
|
|
have_fds = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (select_send) { |
|
|
|
FD_SET(pnode->hSocket, &fdsetSend); |
|
|
|
FD_SET(pnode->hSocket, &fdsetSend); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (select_recv) { |
|
|
|
{ |
|
|
|
|
|
|
|
if (!pnode->fPauseRecv) |
|
|
|
|
|
|
|
FD_SET(pnode->hSocket, &fdsetRecv); |
|
|
|
FD_SET(pnode->hSocket, &fdsetRecv); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1229,9 +1234,15 @@ void CConnman::ThreadSocketHandler() |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Receive
|
|
|
|
// Receive
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
bool recvSet = false; |
|
|
|
|
|
|
|
bool sendSet = false; |
|
|
|
|
|
|
|
bool errorSet = false; |
|
|
|
if (pnode->hSocket == INVALID_SOCKET) |
|
|
|
if (pnode->hSocket == INVALID_SOCKET) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError)) |
|
|
|
recvSet = FD_ISSET(pnode->hSocket, &fdsetRecv); |
|
|
|
|
|
|
|
sendSet = FD_ISSET(pnode->hSocket, &fdsetSend); |
|
|
|
|
|
|
|
errorSet = FD_ISSET(pnode->hSocket, &fdsetError); |
|
|
|
|
|
|
|
if (recvSet || errorSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1286,9 +1297,7 @@ void CConnman::ThreadSocketHandler() |
|
|
|
//
|
|
|
|
//
|
|
|
|
// Send
|
|
|
|
// Send
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (pnode->hSocket == INVALID_SOCKET) |
|
|
|
if (sendSet) |
|
|
|
continue; |
|
|
|
|
|
|
|
if (FD_ISSET(pnode->hSocket, &fdsetSend)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(pnode->cs_vSend); |
|
|
|
LOCK(pnode->cs_vSend); |
|
|
|
size_t nBytes = SocketSendData(pnode); |
|
|
|
size_t nBytes = SocketSendData(pnode); |
|
|
|