From: Michael Tremer Date: Fri, 31 Jan 2025 14:38:24 +0000 (+0000) Subject: httpclient: Configure some more sensible defaults X-Git-Tag: 0.9.30~211 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=091bf9836a5c88089a76f8976ed905fcdde5a286;p=pakfire.git httpclient: Configure some more sensible defaults Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/httpclient.c b/src/pakfire/httpclient.c index fc8436ad..fc1cb27a 100644 --- a/src/pakfire/httpclient.c +++ b/src/pakfire/httpclient.c @@ -411,8 +411,8 @@ static int pakfire_httpclient_setup_curl(struct pakfire_httpclient* self) { return r; } - // Limit parallel transfers - r = curl_multi_setopt(self->curl, CURLMOPT_MAXCONNECTS, self->max_parallel); + // Set the number of open idle connections + r = curl_multi_setopt(self->curl, CURLMOPT_MAXCONNECTS, 16); if (r) { ERROR(self->ctx, "Could not set max parallel transfers: %s\n", curl_multi_strerror(r)); @@ -420,6 +420,24 @@ static int pakfire_httpclient_setup_curl(struct pakfire_httpclient* self) { return r; } + // Do not open more than eight connections to the same host + r = curl_multi_setopt(self->curl, CURLMOPT_MAX_HOST_CONNECTIONS, 8); + if (r) { + ERROR(self->ctx, "Could not set max host connections: %s\n", + curl_multi_strerror(r)); + + return r; + } + + // Limit total number of open connections + r = curl_multi_setopt(self->curl, CURLMOPT_MAX_TOTAL_CONNECTIONS, 64); + if (r) { + ERROR(self->ctx, "Could not set max total connections: %s\n", + curl_multi_strerror(r)); + + return r; + } + return 0; }