mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:11:37 +00:00
sock: align exception monitoring between poll() and select() backends #36665
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36665
Loading…
Reference in a new issue
No description provided.
Delete branch "2610_sock_select_poll"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On non-Linux platforms,
WaitManymonitors every socket for exceptional conditions, even when we are not looking to read from it. On Linux, it never monitors those.Monitoring for certain socket events on some platforms but not others is inconsistent and surprising. In this instance it probably means these cases receive less testing as well, since they are ignored on our most well-tested platform.
Fix this issue by only monitoring for exceptional conditions (which is necessary to detect failed connection attempts early on Windows) for sockets we are also waiting to read from.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Base:
dd9d2b919d6a97907417bf9c4f539f182f04cc01Head:
1e0c407377034e9cbb4d52f1f534c06cdf202a36Design and approach
Clarify whether both backends should return matching ErrorEvent results (src/util/sock.cpp:219, head)
The poll path still maps POLLERR and POLLHUP to ErrorEvent without checking requested events; Linux poll can report these conditions even when they were not requested (man7.org). So this change aligns select's exception-set registration but does not align the returned ErrorEvent behavior for send-only or zero-interest entries. This difference reaches an HTTPServer path: buffered clients can be registered with event 0, and SocketHandlerConnected calls Receive when ErrorEvent is set. Please apply a consistent requested-event policy to both backends, or narrow and document the change as select-set alignment rather than caller-visible event alignment.
Full review report
ACK
1e0c407377Indeed the
poll(2)andselect(2)branches seem to be inconsistent.Thanks!
Just a note to other reviewers: it looks fine to just drop
FD_SET(s, &err);instead of moving it to underif (events.requested & RecvEvent). We do not expect and do not care about any "exceptional conditions":from
select(2):from
poll(2):Also, our
poll()branch does not doPOLLPRI.However! https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select:
So,
FD_SET(s, &err);is needed on Windows to handle our non-blockingconnect()s.utACK
1e0c407377ACK
1e0c407377Validated a prefinal form in freebsd
ACK
1e0c407377built and tested on macos/arm64, clauded up a test that send an "exceptional" byte on master and compared to branch. Came to same conclusions as vasild in https://github.com/bitcoin/bitcoin/pull/36665/changes#r4378669650
This is a clean solution to the discrepency
Show Signature
pinheadmz's public key is on openpgp.org
Backported to
32.xin #36658.Backported to
31.xin #36661.Backported to
30.xin #36664.Backported to
29.xin #36666.post-merge crACK
1e0c407377post-merge ACK
1e0c407377Post-merge ACK
The underlying issue has been disclosed in https://bitcoincore.org/en/2026/10/28/disclose-tcp-oom/
I have some potential followups in 2026/10/sock-error-handler
(an earlier version also did something similar to https://github.com/bitcoin/bitcoin/pull/36676)
See also https://github.com/bitcoin/bitcoin/pull/36688