diff --git a/lix/libstore/remote-store.cc b/lix/libstore/remote-store.cc index b4b5e1693..ecff180f4 100644 --- a/lix/libstore/remote-store.cc +++ b/lix/libstore/remote-store.cc @@ -66,7 +66,7 @@ kj::Promise>> RemoteStore::openAndInitConnec try { auto conn = openConnection(); try { - initConnection(*conn); + TRY_AWAIT(initConnection(*conn)); co_return conn; } catch (...) { failed = true; @@ -76,8 +76,8 @@ try { co_return result::current_exception(); } -void RemoteStore::initConnection(Connection & conn) -{ +kj::Promise> RemoteStore::initConnection(Connection & conn) +try { /* Send the magic greeting, check for the reply. */ try { conn.store = this; @@ -112,12 +112,14 @@ void RemoteStore::initConnection(Connection & conn) throw Error("cannot open connection to remote store '%s': %s", getUri(), e.what()); } - setOptions(conn); + TRY_AWAIT(setOptions(conn)); + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } - -void RemoteStore::setOptions(Connection & conn) -{ +kj::Promise> RemoteStore::setOptions(Connection & conn) +try { StringSink command; command << WorkerProto::Op::SetOptions @@ -157,9 +159,11 @@ void RemoteStore::setOptions(Connection & conn) conn.to.flush(); auto ex = conn.processStderr(); if (ex) std::rethrow_exception(ex); + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } - RemoteStore::ConnectionHandle::~ConnectionHandle() { if (!daemonException && std::uncaught_exceptions()) { @@ -187,7 +191,7 @@ try { kj::Promise> RemoteStore::setOptions() try { - setOptions(*(TRY_AWAIT(getConnection()).handle)); + TRY_AWAIT(setOptions(*(TRY_AWAIT(getConnection()).handle))); co_return result::success(); } catch (...) { co_return result::current_exception(); diff --git a/lix/libstore/remote-store.hh b/lix/libstore/remote-store.hh index 389b05c26..b937bb340 100644 --- a/lix/libstore/remote-store.hh +++ b/lix/libstore/remote-store.hh @@ -181,11 +181,11 @@ protected: kj::Promise>> openAndInitConnection(); - void initConnection(Connection & conn); + kj::Promise> initConnection(Connection & conn); ref> connections; - virtual void setOptions(Connection & conn); + virtual kj::Promise> setOptions(Connection & conn); kj::Promise> setOptions() override; diff --git a/lix/libstore/ssh-store.cc b/lix/libstore/ssh-store.cc index 7d3810e12..3bb75dadb 100644 --- a/lix/libstore/ssh-store.cc +++ b/lix/libstore/ssh-store.cc @@ -5,6 +5,7 @@ #include "lix/libstore/worker-protocol.hh" #include "lix/libutil/pool.hh" #include "lix/libstore/ssh.hh" +#include "lix/libutil/result.hh" #include "lix/libutil/strings.hh" namespace nix { @@ -77,7 +78,7 @@ protected: SSH ssh; - void setOptions(RemoteStore::Connection & conn) override + kj::Promise> setOptions(RemoteStore::Connection & conn) override { /* TODO Add a way to explicitly ask for some options to be forwarded. One option: A way to query the daemon for its @@ -85,6 +86,7 @@ protected: forward-cores or forward-overridden-cores that only override the requested settings. */ + return {result::success()}; }; };