aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/remote-store.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 2373bbdc7..3188d9330 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -1067,15 +1067,27 @@ void RemoteStore::ConnectionHandle::withFramedSink(std::function<void(Sink & sin
Finally joinStderrThread([&]()
{
- stderrThread.join();
- if (ex) {
- std::rethrow_exception(ex);
+ if (stderrThread.joinable()) {
+ stderrThread.join();
+ if (ex) {
+ try {
+ std::rethrow_exception(ex);
+ } catch (...) {
+ ignoreException();
+ }
+ }
}
});
- FramedSink sink((*this)->to, ex);
- fun(sink);
- sink.flush();
+ {
+ FramedSink sink((*this)->to, ex);
+ fun(sink);
+ sink.flush();
+ }
+
+ stderrThread.join();
+ if (ex)
+ std::rethrow_exception(ex);
}
}