Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl_poll may not ignore EINTR if 0 file descriptors are passed #11135

Closed
pitrou opened this issue May 18, 2023 · 2 comments
Closed

Curl_poll may not ignore EINTR if 0 file descriptors are passed #11135

pitrou opened this issue May 18, 2023 · 2 comments

Comments

@pitrou
Copy link
Contributor

pitrou commented May 18, 2023

I encountered this potential issue when trying to investigate a user report.

In the general case, Curl_poll will translate EINTR into a no-error return so that the caller may retry:

curl/lib/select.c

Lines 312 to 318 in a9f8fe2

r = poll(ufds, nfds, pending_ms);
if(r <= 0) {
if((r == -1) && (SOCKERRNO == EINTR))
/* make EINTR from select or poll not a "lethal" error */
r = 0;
return r;
}

However, if no valid fds are passed, Curl_poll delegates to Curl_wait_ms which doesn't try to eliminate EINTR errors:

curl/lib/select.c

Lines 94 to 104 in a9f8fe2

r = poll(NULL, 0, (int)timeout_ms);
#else
{
struct timeval pending_tv;
r = select(0, NULL, NULL, NULL, curlx_mstotv(&pending_tv, timeout_ms));
}
#endif /* HAVE_POLL_FINE */
#endif /* USE_WINSOCK */
if(r)
r = -1;
return r;

Curl_poll is used from Curl_multi_wait where it's not obvious whether a non-zero number of file descriptors is always found.

This might be a red herring, but I suppose it wouldn't hurt fixing Curl_wait_ms (and/or Curl_poll) in any case.

@bagder
Copy link
Member

bagder commented May 18, 2023

@pitrou are you up to making a PR for this?

@pitrou
Copy link
Contributor Author

pitrou commented May 18, 2023

I can try to do that.

pitrou added a commit to pitrou/curl that referenced this issue May 18, 2023
pitrou added a commit to pitrou/curl that referenced this issue May 18, 2023
This was already done for the poll() and select() calls
made directly from Curl_poll(), but was missed in
Curl_wait_ms(), which is called when there are no fds
to wait on.

Fixes curl#11135
@bagder bagder closed this as completed in d65321f May 19, 2023
bch pushed a commit to bch/curl that referenced this issue Jul 19, 2023
This was already done for the poll() and select() calls
made directly from Curl_poll(), but was missed in
Curl_wait_ms(), which is called when there are no fds
to wait on.

Fixes curl#11135
Closes curl#11143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants