Skip to content

Commit

Permalink
Fix Curl downloader not observing set task limits (axmolengine#2067)
Browse files Browse the repository at this point in the history
* Delete unused variable

* Remove invalid comment

* Fix Curl downloader not observing set task limits
  • Loading branch information
smilediver authored Aug 2, 2024
1 parent 807a91b commit 39b6560
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit 39b6560

Please sign in to comment.