about summary refs log tree commit diff
path: root/src/libutil/pool.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-10-16T21·36+0200
committerEelco Dolstra <edolstra@gmail.com>2018-10-16T21·36+0200
commit79e358ce6d2a2c34f365c24d68ddbab7461380f8 (patch)
tree62a7ca153cb1021bcebeb58776ceaacc3efc616e /src/libutil/pool.hh
parentba51100d64c18f627f97e606c4884ba2fb78dfa0 (diff)
RemoteStore: Close connection if an exception occurs
Fixes #2075.
Diffstat (limited to 'src/libutil/pool.hh')
-rw-r--r--src/libutil/pool.hh6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libutil/pool.hh b/src/libutil/pool.hh
index 0b142b0597..d49067bb95 100644
--- a/src/libutil/pool.hh
+++ b/src/libutil/pool.hh
@@ -97,6 +97,7 @@ public:
     private:
         Pool & pool;
         std::shared_ptr<R> 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>(r));
+                if (!bad)
+                    state_->idle.push_back(ref<R>(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()