]> git.ipfire.org Git - pakfire.git/commitdiff
httpclient: Configure some more sensible defaults
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 31 Jan 2025 14:38:24 +0000 (14:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 31 Jan 2025 14:38:24 +0000 (14:38 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/httpclient.c

index fc8436adb9364ca0db95f51c9abbe498215dddc3..fc1cb27a8569e6a5885dc2efb0e2d7be565313b3 100644 (file)
@@ -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;
 }