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 Curl downloader not observing set task limits #2067

Merged
merged 3 commits into from
Aug 2, 2024
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
12 changes: 7 additions & 5 deletions core/network/Downloader-curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
// https://curl.se/libcurl/c/curl_easy_getinfo.html
// https://curl.se/libcurl/c/curl_easy_setopt.html

# define AX_CURL_POLL_TIMEOUT_MS 1000 // wait until DNS query done
# define AX_CURL_POLL_TIMEOUT_MS 1000

enum
{
Expand Down Expand Up @@ -611,7 +611,6 @@ class DownloaderCURL::Impl : public std::enable_shared_from_this<DownloaderCURL:

// remove from multi-handle
curl_multi_remove_handle(curlmHandle, curlHandle);
bool reinited = false;
do
{
auto coTask = static_cast<DownloadTaskCURL*>(task->_coTask.get());
Expand All @@ -623,7 +622,7 @@ class DownloaderCURL::Impl : public std::enable_shared_from_this<DownloaderCURL:
curl_easy_getinfo(curlHandle, CURLINFO_RESPONSE_CODE, &responeCode);
fmt::format_to(std::back_inserter(errorMsg), FMT_COMPILE(": {}"), responeCode);
}

coTask->setErrorDesc(DownloadTask::ERROR_IMPL_INTERNAL, errCode, std::move(errorMsg));
break;
}
Expand Down Expand Up @@ -669,9 +668,12 @@ class DownloaderCURL::Impl : public std::enable_shared_from_this<DownloaderCURL:
}

// process tasks in _requestList
auto size = coTaskMap.size();
while (0 == countOfMaxProcessingTasks || size < countOfMaxProcessingTasks)
while (true)
{
// Check for set task limit
if (countOfMaxProcessingTasks && coTaskMap.size() >= countOfMaxProcessingTasks)
break;

// get task wrapper from request queue
std::shared_ptr<DownloadTask> task;
{
Expand Down