| 1610 | } |
| 1611 | |
| 1612 | void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes, |
| 1613 | const std::set<SOCKET>& recv_set, |
| 1614 | const std::set<SOCKET>& send_set, |
| 1615 | const std::set<SOCKET>& error_set) |
| 1616 | { |
| 1617 | for (CNode* pnode : nodes) { |
| 1618 | if (interruptNet) |
| 1619 | return; |
| 1620 | |
| 1621 | // |
| 1622 | // Receive |
| 1623 | // |
| 1624 | bool recvSet = false; |
| 1625 | bool sendSet = false; |
| 1626 | bool errorSet = false; |
| 1627 | { |
| 1628 | LOCK(pnode->m_sock_mutex); |
| 1629 | if (!pnode->m_sock) { |
| 1630 | continue; |
| 1631 | } |
| 1632 | recvSet = recv_set.count(pnode->m_sock->Get()) > 0; |
| 1633 | sendSet = send_set.count(pnode->m_sock->Get()) > 0; |
| 1634 | errorSet = error_set.count(pnode->m_sock->Get()) > 0; |
| 1635 | } |
| 1636 | if (recvSet || errorSet) |
| 1637 | { |
| 1638 | // typical socket buffer is 8K-64K |
| 1639 | uint8_t pchBuf[0x10000]; |
| 1640 | int nBytes = 0; |
| 1641 | { |
| 1642 | LOCK(pnode->m_sock_mutex); |
| 1643 | if (!pnode->m_sock) { |
| 1644 | continue; |
| 1645 | } |
| 1646 | nBytes = pnode->m_sock->Recv(pchBuf, sizeof(pchBuf), MSG_DONTWAIT); |
| 1647 | } |
| 1648 | if (nBytes > 0) |
| 1649 | { |
| 1650 | bool notify = false; |
| 1651 | if (!pnode->ReceiveMsgBytes({pchBuf, (size_t)nBytes}, notify)) { |
| 1652 | pnode->CloseSocketDisconnect(); |
| 1653 | } |
| 1654 | RecordBytesRecv(nBytes); |
| 1655 | if (notify) { |
| 1656 | size_t nSizeAdded = 0; |
| 1657 | auto it(pnode->vRecvMsg.begin()); |
| 1658 | for (; it != pnode->vRecvMsg.end(); ++it) { |
| 1659 | // vRecvMsg contains only completed CNetMessage |
| 1660 | // the single possible partially deserialized message are held by TransportDeserializer |
| 1661 | nSizeAdded += it->m_raw_message_size; |
| 1662 | } |
| 1663 | { |
| 1664 | LOCK(pnode->cs_vProcessMsg); |
| 1665 | pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), it); |
| 1666 | pnode->nProcessQueueSize += nSizeAdded; |
| 1667 | pnode->fPauseRecv = pnode->nProcessQueueSize > nReceiveFloodSize; |
| 1668 | } |
| 1669 | WakeMessageHandler(); |
nothing calls this directly
no test coverage detected