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

fix: workaround curl_multi_poll returning an error on EINTR #11649

Merged
merged 2 commits into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions google/cloud/internal/curl_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,27 @@ Status CurlImpl::PerformWorkUntil(absl::FunctionRef<bool()> predicate) {
Status CurlImpl::WaitForHandles(int& repeats) {
int const timeout_ms = 1000;
int numfds = 0;
CURLMcode result;
#if CURL_AT_LEAST_VERSION(7, 66, 0)
CURLMcode result =
curl_multi_poll(multi_.get(), nullptr, 0, timeout_ms, &numfds);
// Use curl_multi_poll()
#if CURL_AT_LEAST_VERSION(7, 84, 0)
// Work around https://github.com/curl/curl/issues/11135 by retrying
// when EINTR fails poll(). We want to retry so that post-poll()
// curl_multi bookkeeping code runs.
do {
errno = 0;
result = curl_multi_poll(multi_.get(), nullptr, 0, timeout_ms, &numfds);
} while (result == CURLM_UNRECOVERABLE_POLL && errno == EINTR);
#else
// EINTR will be simply ignored by curl_multi_poll().
result = curl_multi_poll(multi_.get(), nullptr, 0, timeout_ms, &numfds);
#endif
TRACE_STATE() << ", numfds=" << numfds << ", result=" << result
<< ", repeats=" << repeats;
if (result != CURLM_OK) return AsStatus(result, __func__);
#else
CURLMcode result =
curl_multi_wait(multi_.get(), nullptr, 0, timeout_ms, &numfds);
// Use curl_multi_wait()
result = curl_multi_wait(multi_.get(), nullptr, 0, timeout_ms, &numfds);
TRACE_STATE() << ", numfds=" << numfds << ", result=" << result
<< ", repeats=" << repeats;
if (result != CURLM_OK) return AsStatus(result, __func__);
Expand Down