From 0b77ba698092e388d5c6fec6065a9004ea2f264f Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 21 Mar 2024 21:45:17 +0100 Subject: [PATCH] libstore: remove one Resource::good flag usage of this flag previously kept connections open much longer than necessary, and at the same time obscured that a connection was being dropped when it *was* set. new variable names clarify this somewhat. Change-Id: I11f6f08f37a5e4dc04ea6c6036ea589154b121c6 --- src/libstore/legacy-ssh-store.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index 2d8667a85..58d519bf7 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -46,7 +46,6 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor FdSink to; FdSource from; ServeProto::Version remoteVersion; - bool good = true; /** * Coercion to `ServeProto::ReadConn`. This makes it easy to use the @@ -97,8 +96,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor , host(host) , connections(make_ref>( std::max(1, (int) maxConnections), - [this]() { return openConnection(); }, - [](const ref & r) { return r->good; } + [this]() { return openConnection(); } )) , master( host, @@ -199,7 +197,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor try { copyNAR(source, conn->to); } catch (...) { - conn->good = false; + auto _dropConnDuringUnwind = std::move(conn); throw; } conn->to.flush(); @@ -212,7 +210,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor try { copyNAR(source, conn->to); } catch (...) { - conn->good = false; + auto _dropConnDuringUnwind = std::move(conn); throw; } conn->to