#36716 net: stop monitoring select exceptions outside Windows

ReviewabilityReviewsAgreementSize
#36716 Sjors net: stop monitoring select exceptions outside WindowsReady0Crickets23
  • Prevent node event loops on POSIX platforms from spinning in busy loops when peers send TCP urgent data
  • Keep connection failure detection working on Windows without stalling the network thread
  • Ready to review
  • No review verdicts recorded
  • No substantive review comments yet
  • Suggested extending the same socket exception logic to the HTTP server (pinheadmz)
  • 23 lines added or modified outside tests
  • 0 lines added or modified in tests
  • 0 lines removed in total
  • 3 files, 2 commits
P2P#20 of 71
P2 · DoS protection
  • P2 because incoming TCP urgent data can leave socket exceptions pending on POSIX systems
  • Fixing this avoids a potential denial of service from the P2P event loop spinning continuously
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Restricts socket exception monitoring in select() to Windows, and disconnects established peers on Windows if an exception condition occurs. It also adds documentation explaining why Bitcoin Core's P2P layer does not enable SO_OOBINLINE.

Problem: Incoming TCP urgent data sets the socket exception condition in select(). On POSIX systems where urgent data is not read, this can leave the exception pending and cause the network event loop to spin in a busy loop. Bitcoin Core does not use out-of-band data, but Windows still requires monitoring the exception set to detect failed non-blocking connect calls.

Evidence of importance:

  • Commit 1fde57f1de states: 'Windows needs select's exception set to detect failed non-blocking connects. On other platforms, a TCP urgent pointer can leave the exception set pending even when no data is readable. Only monitor it on Windows, and disconnect established P2P peers if it is set.'

Risk of a mistake: medium (p2p). Altering select() socket event handling could inadvertently ignore connection failure errors on non-Windows platforms or disconnect valid peers on Windows.

Changed since the previous assessment: No functional changes to the patch; previous description had no patch diff attached.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • reviewer: pinheadmz to review or respond to author's preference for an HTTP followup 2026-11-01

Agreement

Crickets

no substantive comment either way

Thread notes: Sjors replied to pinheadmz's suggestion regarding HTTP server exception handling, preferring a followup.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
pinheadmz (member)suggestion, scopeApply the same exception-handling logic and urgent-data disconnect test to HTTP in httpserver.cppanswered · author prefers handling HTTP separately in a followup but is open to doing it hereansweredyes2026-10-31: 'Mine as well apply the same logic to HTTP, probably right here'
Status from: 2026-11-01: Sjors: 'My preference is to fix HTTP separately as a followup, but I'm open to doing it here.'

Participants:

  • pinheadmz (member, neutral, 1 statements 2026-10-31 to 2026-10-31): suggested applying the same logic to the HTTP server

Files

0 lines under test/bench/ci.

  • src/net.cpp +12/-0
  • src/netbase.cpp +8/-0
  • src/util/sock.cpp +3/-0

Card

The short text the ranking pass compares across PRs.

Stops monitoring socket exception sets in select() on non-Windows platforms, and disconnects established P2P peers on Windows if an exception triggers. On POSIX systems, TCP urgent data or out-of-band pointers can leave socket exceptions pending without readable data, causing network event loops to busy-spin. This serves as an alternative to PR 36688, avoiding SO_OOBINLINE per RFC 6093 recommendations.

Data

dossier JSON · extract JSON · model ledger, generated 2026-11-02T01:11, confidence high, input hash a6bdaa566758dd05
thread read through 2026-11-01 (2 statements), head 8754e5c1c4
labels: P2P

Categories

P2P

P2 · DoS protection

Prevents a potential busy loop in the P2P network event loop caused by incoming TCP urgent data. As noted in commit 1fde57f1de, on POSIX systems 'a TCP urgent pointer can leave the exception set pending even when no data is readable', which causes select() to spin continuously.

Membership: Matches the P2P label and modifies connection management and socket polling in src/net.cpp and src/netbase.cpp.

Factors: security/stability 2, bug 2, performance 1, user value 0, leverage 0