MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SocketHandler

Method SocketHandler

src/net.cpp:2118–2145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2116}
2117
2118void CConnman::SocketHandler()
2119{
2120 AssertLockNotHeld(m_nodes_mutex);
2121 AssertLockNotHeld(m_total_bytes_sent_mutex);
2122
2123 Sock::EventsPerSock events_per_sock;
2124
2125 {
2126 const NodesSnapshot snap{*this, /*shuffle=*/false};
2127
2128 const auto timeout = std::chrono::milliseconds(SELECT_TIMEOUT_MILLISECONDS);
2129
2130 // Check for the readiness of the already connected sockets and the
2131 // listening sockets in one call ("readiness" as in poll(2) or
2132 // select(2)). If none are ready, wait for a short while and return
2133 // empty sets.
2134 events_per_sock = GenerateWaitSockets(snap.Nodes());
2135 if (events_per_sock.empty() || !events_per_sock.begin()->first->WaitMany(timeout, events_per_sock)) {
2136 m_interrupt_net->sleep_for(timeout);
2137 }
2138
2139 // Service (send/receive) each of the already connected nodes.
2140 SocketHandlerConnected(snap.Nodes(), events_per_sock);
2141 }
2142
2143 // Accept new connections from listening sockets.
2144 SocketHandlerListening(events_per_sock);
2145}
2146
2147void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes,
2148 const Sock::EventsPerSock& events_per_sock)

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.45
WaitManyMethod · 0.45
beginMethod · 0.45
sleep_forMethod · 0.45

Tested by

no test coverage detected