From 6378f0bb328437de759f7ed8405fcafbb3bcac54 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 May 2022 13:27:13 +0200 Subject: [PATCH] RemoteStore::queryRealisationUncached(): Fix potential noexcept violation --- src/libstore/remote-store.cc | 56 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 14aeba75c..bc36aef5d 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -718,36 +718,34 @@ void RemoteStore::registerDrvOutput(const Realisation & info) void RemoteStore::queryRealisationUncached(const DrvOutput & id, Callback> callback) noexcept { - auto conn(getConnection()); - - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) { - warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4"); - try { - callback(nullptr); - } catch (...) { return callback.rethrow(); } - } - - conn->to << wopQueryRealisation; - conn->to << id.to_string(); - conn.processStderr(); - - auto real = [&]() -> std::shared_ptr { - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { - auto outPaths = worker_proto::read( - *this, conn->from, Phantom> {}); - if (outPaths.empty()) - return nullptr; - return std::make_shared(Realisation { .id = id, .outPath = *outPaths.begin() }); - } else { - auto realisations = worker_proto::read( - *this, conn->from, Phantom> {}); - if (realisations.empty()) - return nullptr; - return std::make_shared(*realisations.begin()); - } - }(); - try { + auto conn(getConnection()); + + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) { + warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4"); + return callback(nullptr); + } + + conn->to << wopQueryRealisation; + conn->to << id.to_string(); + conn.processStderr(); + + auto real = [&]() -> std::shared_ptr { + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { + auto outPaths = worker_proto::read( + *this, conn->from, Phantom> {}); + if (outPaths.empty()) + return nullptr; + return std::make_shared(Realisation { .id = id, .outPath = *outPaths.begin() }); + } else { + auto realisations = worker_proto::read( + *this, conn->from, Phantom> {}); + if (realisations.empty()) + return nullptr; + return std::make_shared(*realisations.begin()); + } + }(); + callback(std::shared_ptr(real)); } catch (...) { return callback.rethrow(); } }