select: use poll() if existing, avoid poll() with no sockets #15096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
poll() on macOS 10.12 was deemed broken in 2016 when we discovered that it misbehaves when provided with no sockets to wait for. The HAVE_POLL_FINE is used to mark a poll() implementation that behaves correctly: it should still wait the timeout time.
curl has therefore opted to use select() on Apple operating systems ever since. To avoid the risk that this or other breakage cause problems.
However, using select() internally is also bad because it suffers from problems when using file descriptors beyond 1024.
This change makes curl use poll() if there is one present, but if there is no sockets to wait for it avoids using poll() and instead falls back to select() - but without any sockets to wait for there is no 1024 problem. This removes all previous special-handling involving
HAVE_POLL_FINE
.ref: https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/