From 52f741c23af84ebb67f7295600069a9c6e83aec4 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 5 Apr 2024 03:52:34 +0200 Subject: [PATCH] Revert "libutil: remove Pool::Handle::bad" This reverts commit 792844fb861ea7367ac2316c78fec055363f2f9e. Change-Id: I3ca208b62edfd5cd1199478f75cd2edf19a364f6 --- src/libstore/remote-store.cc | 1 + src/libutil/pool.hh | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 3188d9330..20c1c50f2 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -155,6 +155,7 @@ void RemoteStore::setOptions(Connection & conn) RemoteStore::ConnectionHandle::~ConnectionHandle() { if (!daemonException && std::uncaught_exceptions()) { + handle.markBad(); debug("closing daemon connection because of an exception"); } } diff --git a/src/libutil/pool.hh b/src/libutil/pool.hh index 2f6d30130..b7a749e3a 100644 --- a/src/libutil/pool.hh +++ b/src/libutil/pool.hh @@ -103,6 +103,7 @@ public: private: Pool & pool; std::shared_ptr r; + bool bad = false; friend Pool; @@ -118,7 +119,7 @@ public: if (!r) return; { auto state_(pool.state.lock()); - if (!std::uncaught_exceptions()) + if (!bad && !std::uncaught_exceptions()) state_->idle.push_back(ref(r)); assert(state_->inUse); state_->inUse--; @@ -128,6 +129,8 @@ public: R * operator -> () { return &*r; } R & operator * () { return *r; } + + void markBad() { bad = true; } }; Handle get()