diff options
| author | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-11 16:38:49 -0300 |
|---|---|---|
| committer | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-11 16:38:49 -0300 |
| commit | c5f6b52c0d1d65f7bf8cd745a7a212bc6b2fe318 (patch) | |
| tree | 7ad2835cd6cdca8808b202036525d0cde2380607 /src/net.h | |
| parent | a83fae37099cb102beb5a4c174a4abe6ef3f24a4 (diff) | |
net: replace peer select loop with poll
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 15 |
1 files changed, 6 insertions, 9 deletions
| @@ -98,19 +98,16 @@ static const int BTF_INCOMPLETE_MESSAGE_TIMEOUT_SECS = 2 * 60; | |||
| 98 | 98 | ||
| 99 | // Ceiling on simultaneous connections. | 99 | // Ceiling on simultaneous connections. |
| 100 | // | 100 | // |
| 101 | // ThreadSocketHandler watches every peer through one select(), and select() | 101 | // ThreadSocketHandler watches every peer in one socket loop. This used to be a |
| 102 | // cannot watch more descriptors than FD_SETSIZE. On Windows FD_SET simply | 102 | // select() loop, which made FD_SETSIZE the real limit and silently starved |
| 103 | // stops adding once the set is full -- no error, no log -- so every socket | 103 | // sockets past that bitmap. It is now poll()/WSAPoll(), so the ceiling below is |
| 104 | // past the limit stays open and is never read again. Nothing capped vNodes, | 104 | // a deliberate resource bound rather than a descriptor-set accident. |
| 105 | // so a node accepted connections it had no way to service, and because new | ||
| 106 | // entries go on the end of vNodes it was always the newest connection that | ||
| 107 | // starved, including the ones dialed to fix connectivity. | ||
| 108 | // | 105 | // |
| 109 | // Measured on two nodes before this ceiling existed: 277 and 90 CNode objects | 106 | // Measured on two nodes before this ceiling existed: 277 and 90 CNode objects |
| 110 | // against 93 and 90 live sockets, and a status bar reporting hundreds of | 107 | // against 93 and 90 live sockets, and a status bar reporting hundreds of |
| 111 | // peers for a node that was really talking to thirty. | 108 | // peers for a node that was really talking to thirty. |
| 112 | // | 109 | // |
| 113 | // 125 is Bitcoin's number and sits far below FD_SETSIZE on both platforms. | 110 | // 125 is Bitcoin's number and remains a conservative public-node default. |
| 114 | static const unsigned int MAX_CONNECTIONS = 125; | 111 | static const unsigned int MAX_CONNECTIONS = 125; |
| 115 | 112 | ||
| 116 | // A node marked for disconnect is normally held until its buffers drain, so | 113 | // A node marked for disconnect is normally held until its buffers drain, so |
| @@ -142,7 +139,7 @@ static const int BTF_BEHIND_WARN_INTERVAL_SECS = 5 * 60; | |||
| 142 | // | 139 | // |
| 143 | // These counters exist so it can. Cheap to keep, and they name the failures | 140 | // These counters exist so it can. Cheap to keep, and they name the failures |
| 144 | // that actually happened rather than the ones that sound impressive. | 141 | // that actually happened rather than the ones that sound impressive. |
| 145 | extern int nPeersWatched; // peers in the last select() set | 142 | extern int nPeersWatched; // peers in the last poll() set |
| 146 | extern int64 nBlocksReceived; // blocks handed to ProcessBlock | 143 | extern int64 nBlocksReceived; // blocks handed to ProcessBlock |
| 147 | extern int64 nBlocksWithoutParent; // ...of those, how many arrived orphaned | 144 | extern int64 nBlocksWithoutParent; // ...of those, how many arrived orphaned |
| 148 | 145 | ||