From 091bf9836a5c88089a76f8976ed905fcdde5a286 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 31 Jan 2025 14:38:24 +0000 Subject: [PATCH] httpclient: Configure some more sensible defaults Signed-off-by: Michael Tremer --- src/pakfire/httpclient.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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; } -- 2.39.5