tool: fix memory use in parallel mode

The curl tool was creating a new transfer every time it checked if
it needed to add one to reach max parallelism. This led to eventually
all configured transfers to have easy handles created.

Limit the creation again to the ones needed for max parallelism.

scorecard.py: set --out-null only for curl versions that support it

Closes #22277
This commit is contained in:
Stefan Eissing 2026-07-08 14:15:10 +02:00 committed by Daniel Stenberg
parent b093d88447
commit eb73af253c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 19 additions and 2 deletions

View file

@ -1552,7 +1552,13 @@ static CURLcode add_parallel_transfers(CURLM *multi, CURLSH *share,
return CURLE_UNKNOWN_OPTION;
}
if(nxfers < (curl_off_t)(global->parallel_max * 2)) {
if(all_added >= global->parallel_max) {
/* we are at max parallelism, no need to create more transfers */
*morep = TRUE; /* pretend there are, we have not checked */
return CURLE_OK;
}
/* if the list is empty, create one to kickstart the loop */
if(!transfers) {
bool skipped = FALSE;
do {
result = create_transfer(share, addedp, &skipped);
@ -1560,6 +1566,7 @@ static CURLcode add_parallel_transfers(CURLM *multi, CURLSH *share,
return result;
} while(skipped);
}
/* add transfers until max parallelism is achieved again */
for(per = transfers; per && (all_added < global->parallel_max);
per = per->next) {
if(per->added || per->skip)

View file

@ -729,7 +729,10 @@ class CurlClient:
if extra_args is None:
extra_args = []
if no_save:
extra_args.extend(['--out-null'])
if self.env.curl_version_at_least('8.16.0'):
extra_args.extend(['--out-null'])
else:
extra_args.extend(['-o', '/dev/null'])
else:
extra_args.extend(['-o', 'download_#1.data'])
if limit_rate:

View file

@ -512,6 +512,13 @@ class Env:
def curl_version_string() -> str:
return Env.CONFIG.curl_props["version_string"]
@staticmethod
def curl_version_at_least(min_version) -> bool:
version = Env.curl_version()
return Env.CONFIG.versiontuple(min_version) <= Env.CONFIG.versiontuple(
version
)
@staticmethod
def curl_features_string() -> str:
return Env.CONFIG.curl_props["features_string"]