]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat(http-storage): Make HTTP keep-alive configurable 934/head
authorGregor Jasny <gregor.jasny@logmein.com>
Fri, 1 Oct 2021 06:54:38 +0000 (08:54 +0200)
committerGregor Jasny <gregor.jasny@logmein.com>
Fri, 1 Oct 2021 06:54:38 +0000 (08:54 +0200)
doc/MANUAL.adoc
src/storage/secondary/HttpStorage.cpp

index e29d0a2015179acc7e001ccd950cd40aa2b11509..433f3855972377b5187f415d80ce413e5b16c5ca 100644 (file)
@@ -1080,6 +1080,14 @@ Examples:
 Optional attributes:
 
 * *connect-timeout*: Timeout (in ms) for network connection. The default is 100.
+* *keep-alive*: If *true*, keep the HTTP connection to the storage server open
+to avoid reconnects. The default is *false*.
++
+NOTE: Connection keep-alive is disabled by default because with the current
+HTTP implementation uploads to the remote end might fail in case the server
+closes the connection due to a keep-alive timeout. If the general case with
+short compilation times should be accelerated or the server is configured with
+a long-enough timeout, then connection keep-alive could be enabled.
 * *layout*: How to map key names to the path part of the URL. Available values:
 +
 --
index bf7e5802b00dc6beec9a9914eaca41d18c0d9784..4d5ab2998d33f63cccceac0bb7316befa7fb6102 100644 (file)
@@ -110,6 +110,7 @@ HttpStorageBackend::HttpStorageBackend(const Params& params)
   m_http_client.set_default_headers({
     {"User-Agent", FMT("{}/{}", CCACHE_NAME, CCACHE_VERSION)},
   });
+  m_http_client.set_keep_alive(false);
 
   auto connect_timeout = k_default_connect_timeout;
   auto operation_timeout = k_default_operation_timeout;
@@ -117,6 +118,8 @@ HttpStorageBackend::HttpStorageBackend(const Params& params)
   for (const auto& attr : params.attributes) {
     if (attr.key == "connect-timeout") {
       connect_timeout = parse_timeout_attribute(attr.value);
+    } else if (attr.key == "keep-alive") {
+      m_http_client.set_keep_alive(attr.value == "true");
     } else if (attr.key == "layout") {
       if (attr.value == "bazel") {
         m_layout = Layout::bazel;