Skip to content

Commit 39b6560

Browse files
authored
Fix Curl downloader not observing set task limits (#2067)
* Delete unused variable * Remove invalid comment * Fix Curl downloader not observing set task limits
1 parent 807a91b commit 39b6560

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

core/network/Downloader-curl.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
// https://curl.se/libcurl/c/curl_easy_getinfo.html
5353
// https://curl.se/libcurl/c/curl_easy_setopt.html
5454

55-
# define AX_CURL_POLL_TIMEOUT_MS 1000 // wait until DNS query done
55+
# define AX_CURL_POLL_TIMEOUT_MS 1000
5656

5757
enum
5858
{
@@ -611,7 +611,6 @@ class DownloaderCURL::Impl : public std::enable_shared_from_this<DownloaderCURL:
611611

612612
// remove from multi-handle
613613
curl_multi_remove_handle(curlmHandle, curlHandle);
614-
bool reinited = false;
615614
do
616615
{
617616
auto coTask = static_cast<DownloadTaskCURL*>(task->_coTask.get());
@@ -623,7 +622,7 @@ class DownloaderCURL::Impl : public std::enable_shared_from_this<DownloaderCURL:
623622
curl_easy_getinfo(curlHandle, CURLINFO_RESPONSE_CODE, &responeCode);
624623
fmt::format_to(std::back_inserter(errorMsg), FMT_COMPILE(": {}"), responeCode);
625624
}
626-
625+
627626
coTask->setErrorDesc(DownloadTask::ERROR_IMPL_INTERNAL, errCode, std::move(errorMsg));
628627
break;
629628
}
@@ -669,9 +668,12 @@ class DownloaderCURL::Impl : public std::enable_shared_from_this<DownloaderCURL:
669668
}
670669

671670
// process tasks in _requestList
672-
auto size = coTaskMap.size();
673-
while (0 == countOfMaxProcessingTasks || size < countOfMaxProcessingTasks)
671+
while (true)
674672
{
673+
// Check for set task limit
674+
if (countOfMaxProcessingTasks && coTaskMap.size() >= countOfMaxProcessingTasks)
675+
break;
676+
675677
// get task wrapper from request queue
676678
std::shared_ptr<DownloadTask> task;
677679
{

0 commit comments

Comments
 (0)