From 79e358ce6d2a2c34f365c24d68ddbab7461380f8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Oct 2018 23:36:15 +0200 Subject: RemoteStore: Close connection if an exception occurs Fixes #2075. --- src/libutil/pool.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libutil/pool.hh') diff --git a/src/libutil/pool.hh b/src/libutil/pool.hh index 0b142b0597c7..d49067bb95dc 100644 --- a/src/libutil/pool.hh +++ b/src/libutil/pool.hh @@ -97,6 +97,7 @@ public: private: Pool & pool; std::shared_ptr r; + bool bad = false; friend Pool; @@ -112,7 +113,8 @@ public: if (!r) return; { auto state_(pool.state.lock()); - state_->idle.push_back(ref(r)); + if (!bad) + state_->idle.push_back(ref(r)); assert(state_->inUse); state_->inUse--; } @@ -121,6 +123,8 @@ public: R * operator -> () { return &*r; } R & operator * () { return *r; } + + void markBad() { bad = true; } }; Handle get() -- cgit 1.4.1