aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-10-25 11:03:58 +0200
committerVasil Dimov <vd@FreeBSD.org>2021-11-18 13:39:10 +0100
commitf52b6b2d9f482353821da0ef4c485c402a396c8d (patch)
tree71100049a61ca06f6eebb7570d2ef765ac1f4f01 /src/net.h
parentc7eb19ec8302e6a5abd89c0566540c2c862e9121 (diff)
downloadbitcoin-f52b6b2d9f482353821da0ef4c485c402a396c8d.tar.xz
net: split CConnman::SocketHandler()
`CConnman::SocketHandler()` does 3 things: 1. Check sockets for readiness 2. Process ready listening sockets 3. Process ready connected sockets Split the processing (2. and 3.) into separate methods to make the code easier to grasp. Also, move the processing of listening sockets after the processing of connected sockets to make it obvious that there is no dependency and also explicitly release the snapshot before dealing with listening sockets - it is only necessary for the connected sockets part.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index f03883ca54..e8de026573 100644
--- a/src/net.h
+++ b/src/net.h
@@ -1010,7 +1010,30 @@ private:
std::set<SOCKET>& send_set,
std::set<SOCKET>& error_set);
+ /**
+ * Check connected and listening sockets for IO readiness and process them accordingly.
+ */
void SocketHandler();
+
+ /**
+ * Do the read/write for connected sockets that are ready for IO.
+ * @param[in] nodes Nodes to process. The socket of each node is checked against
+ * `recv_set`, `send_set` and `error_set`.
+ * @param[in] recv_set Sockets that are ready for read.
+ * @param[in] send_set Sockets that are ready for send.
+ * @param[in] error_set Sockets that have an exceptional condition (error).
+ */
+ void SocketHandlerConnected(const std::vector<CNode*>& nodes,
+ const std::set<SOCKET>& recv_set,
+ const std::set<SOCKET>& send_set,
+ const std::set<SOCKET>& error_set);
+
+ /**
+ * Accept incoming connections, one from each read-ready listening socket.
+ * @param[in] recv_set Sockets that are ready for read.
+ */
+ void SocketHandlerListening(const std::set<SOCKET>& recv_set);
+
void ThreadSocketHandler();
void ThreadDNSAddressSeed();