about summary refs log tree commit diff
path: root/src/libstore/download.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-14T14·34+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-14T14·38+0200
commit6656ef7b5b798200cf8bf0c7534dbad1e964444d (patch)
tree619ed90d405e78f8d9aade15c988a6625f64e5d6 /src/libstore/download.cc
parent90ad02bf626b885a5dd8967894e2eafc953bdf92 (diff)
Revive binary-caches-parallel-connections
It's a slight misnomer now because it actually limits *all* downloads,
not just binary cache lookups.

Also add a "enable-http2" option to allow disabling use of HTTP/2
(enabled by default).
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r--src/libstore/download.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 2aca0a975bfe..b2d223da960a 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -40,6 +40,8 @@ struct CurlDownloader : public Downloader
     std::random_device rd;
     std::mt19937 mt19937;
 
+    bool enableHttp2;
+
     struct DownloadItem : public std::enable_shared_from_this<DownloadItem>
     {
         CurlDownloader & downloader;
@@ -185,7 +187,8 @@ struct CurlDownloader : public Downloader
             curl_easy_setopt(req, CURLOPT_NOSIGNAL, 1);
             curl_easy_setopt(req, CURLOPT_USERAGENT, ("Nix/" + nixVersion).c_str());
             curl_easy_setopt(req, CURLOPT_PIPEWAIT, 1);
-            curl_easy_setopt(req, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
+            if (downloader.enableHttp2)
+                curl_easy_setopt(req, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
             curl_easy_setopt(req, CURLOPT_WRITEFUNCTION, DownloadItem::writeCallbackWrapper);
             curl_easy_setopt(req, CURLOPT_WRITEDATA, this);
             curl_easy_setopt(req, CURLOPT_HEADERFUNCTION, DownloadItem::headerCallbackWrapper);
@@ -291,7 +294,10 @@ struct CurlDownloader : public Downloader
         curlm = curl_multi_init();
 
         curl_multi_setopt(curlm, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
-        curl_multi_setopt(curlm, CURLMOPT_MAX_TOTAL_CONNECTIONS, 25); // FIXME: configurable
+        curl_multi_setopt(curlm, CURLMOPT_MAX_TOTAL_CONNECTIONS,
+            settings.get("binary-caches-parallel-connections", 25));
+
+        enableHttp2 = settings.get("enable-http2", true);
 
         wakeupPipe.create();
         fcntl(wakeupPipe.readSide.get(), F_SETFL, O_NONBLOCK);