Skip to content

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

@pitrou

Description

@pitrou

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions