diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-03-03T18·35+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-03-03T18·36+0100 |
commit | d1158bb8168804b27508972988d4b85ba9d5e49d (patch) | |
tree | 373f7adac5525ddd9abdb81264755c65669fa2c1 /src/libstore/remote-store.cc | |
parent | 8490ee37a6dbfb66e1b3dbaf88918bea044b143a (diff) |
Cache connection failures
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r-- | src/libstore/remote-store.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 5e62bd3d5aca..1ac2d7b6e786 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -44,13 +44,26 @@ RemoteStore::RemoteStore(const Params & params) : Store(params) , connections(make_ref<Pool<Connection>>( std::max(1, std::stoi(get(params, "max-connections", "1"))), - [this]() { return openConnection(); }, + [this]() { return openConnectionWrapper(); }, [](const ref<Connection> & r) { return r->to.good() && r->from.good(); } )) { } +ref<RemoteStore::Connection> RemoteStore::openConnectionWrapper() +{ + if (failed) + throw Error("opening a connection to remote store ‘%s’ previously failed", getUri()); + try { + return openConnection(); + } catch (...) { + failed = true; + throw; + } +} + + UDSRemoteStore::UDSRemoteStore(const Params & params) : Store(params) , LocalFSStore(params) |