diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-03-24T10·10+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-03-24T10·10+0100 |
commit | 8b7839b608c9d92d432154fd717b77953efe447c (patch) | |
tree | b9550a82b40ba404efff68e13c2d163263139714 /src/libstore | |
parent | c7d44bad000d5f431c05f6c27718d26d2b93bb0f (diff) |
HttpBinaryCacheStore: Make thread-safe
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/http-binary-cache-store.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 1d707c043a72..0aafd0a11467 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -10,7 +10,7 @@ private: Path cacheUri; - ref<Downloader> downloader; + Pool<Downloader> downloaders; public: @@ -18,7 +18,9 @@ public: const Path & secretKeyFile, const Path & _cacheUri) : BinaryCacheStore(localStore, secretKeyFile) , cacheUri(_cacheUri) - , downloader(makeDownloader()) + , downloaders( + std::numeric_limits<size_t>::max(), + []() { return makeDownloader(); }) { if (cacheUri.back() == '/') cacheUri.pop_back(); @@ -36,6 +38,7 @@ protected: bool fileExists(const std::string & path) override { try { + auto downloader(downloaders.get()); DownloadOptions options; options.showProgress = DownloadOptions::no; options.head = true; @@ -55,6 +58,7 @@ protected: std::string getFile(const std::string & path) override { + auto downloader(downloaders.get()); DownloadOptions options; options.showProgress = DownloadOptions::no; return downloader->download(cacheUri + "/" + path, options).data; |