Skip to content

Conversation

@cjen1-msft
Copy link
Contributor

Two warnings were seen recently during testing, EBADF from the libuv polling of the socket and CURL_POLL_IN during shutdown.

When libuv receives a POLLERR from its epoll it surfaces that as EBADF in the poll callback.
This can happen when the other side of a tcp connection abruptly disconnects.
Previously we FAIL logged this and otherwise ignored it, now we pass the error back to curl (CURL_CSELECT_ERR), and INFO log it.

Next, supposing there are several requests to the same address, curl will cache and reuse the socket for this.
However this means that come shutdown the socket may still be alive.
When curl_multi_cleanup is called, this causes the socket to try to poll for any remaining data or a disconnect via CURL_POLL_IN, before immediately calling CURL_POLL_REMOVE.
In this case we simply want curl to shutdown the relevant sockets and thus do not register the new polling.

@cjen1-msft cjen1-msft requested a review from a team as a code owner September 22, 2025 10:30
@achamayou achamayou added auto-backport Automatically backport this PR to LTS branch 6.x-todo PRs which should be backported to 6.x labels Sep 22, 2025
@achamayou
Copy link
Member

When libuv receives a POLLERR from its epoll it surfaces that as EBADF in the poll callback.

@cjen1-msft I can't seem to find a source for this, could you link one please?

@cjen1-msft
Copy link
Contributor Author

cjen1-msft commented Sep 22, 2025

When libuv receives a POLLERR from its epoll it surfaces that as EBADF in the poll callback.

@cjen1-msft I can't seem to find a source for this, could you link one please?

Here is the related libuv issue:
libuv/libuv#3796

And the corresponding bit of libuv documentation:
https://docs.libuv.org/en/v1.x/poll.html#c.uv_poll_start

The situation is a unfortunately vague as libuv only says that something has gone wrong and will never fire an event on that socket again (unless you call uv_start_t again).
And libcurl doesn't give strict semantics on how it responds to CURL_CSELECT_XXX.

So on the curl side we need to notify it of the error and then from staring at the code on their side it seems to do some health checks on the socket before in this case firing a removal event.
If the curl side were instead to reschedule (CURL_POLL_INOUT) then that would end up re-calling uv_start_t on the fd which is also fine.

@cjen1-msft cjen1-msft added this pull request to the merge queue Sep 22, 2025
@cjen1-msft cjen1-msft removed this pull request from the merge queue due to a manual request Sep 22, 2025
@cjen1-msft cjen1-msft added this pull request to the merge queue Sep 23, 2025
Merged via the queue into microsoft:main with commit 4f0f002 Sep 23, 2025
21 checks passed
@cjen1-msft cjen1-msft deleted the curl-snags branch September 23, 2025 09:43
cjen1-msft added a commit to cjen1-msft/CCF that referenced this pull request Sep 23, 2025
Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
cjen1-msft added a commit that referenced this pull request Sep 23, 2025
Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
@cjen1-msft cjen1-msft added the backported This PR was successfully backported to LTS branch label Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.x-todo PRs which should be backported to 6.x auto-backport Automatically backport this PR to LTS branch backported This PR was successfully backported to LTS branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants