about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/download.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 054244c7b8b7..f5304daeefd2 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -183,6 +183,8 @@ struct CurlDownloader : public Downloader
             return 0;
         }
 
+        long lowSpeedTimeout = 300;
+
         void init()
         {
             if (!req) req = curl_easy_init();
@@ -231,6 +233,9 @@ struct CurlDownloader : public Downloader
 
             curl_easy_setopt(req, CURLOPT_CONNECTTIMEOUT, settings.connectTimeout.get());
 
+            curl_easy_setopt(req, CURLOPT_LOW_SPEED_LIMIT, 1L);
+            curl_easy_setopt(req, CURLOPT_LOW_SPEED_TIME, lowSpeedTimeout);
+
             /* If no file exist in the specified path, curl continues to work
                anyway as if netrc support was disabled. */
             curl_easy_setopt(req, CURLOPT_NETRC_FILE, settings.netrcFile.get().c_str());
@@ -422,7 +427,7 @@ struct CurlDownloader : public Downloader
             auto sleepTimeMs =
                 nextWakeup != std::chrono::steady_clock::time_point()
                 ? std::max(0, (int) std::chrono::duration_cast<std::chrono::milliseconds>(nextWakeup - std::chrono::steady_clock::now()).count())
-                : 1000000000;
+                : 10000;
             vomit("download thread waiting for %d ms", sleepTimeMs);
             mc = curl_multi_wait(curlm, extraFDs, 1, sleepTimeMs, &numfds);
             if (mc != CURLM_OK)