From e917c05628abd0ff429c429d0e814532180b9586 Mon Sep 17 00:00:00 2001
From: Will Dietz <w@wdtz.org>
Date: Sat, 3 Mar 2018 14:39:04 -0600
Subject: [PATCH] logging: Don't throw from Activity destructor

Move definition of destructor to logging.cc for
access to util.hh's ignoreException.
---
 src/libutil/logging.cc | 8 ++++++++
 src/libutil/logging.hh | 3 +--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc
index 27a631a37..c1cff5cf9 100644
--- a/src/libutil/logging.cc
+++ b/src/libutil/logging.cc
@@ -221,4 +221,12 @@ bool handleJSONLogMessage(const std::string & msg,
     return true;
 }
 
+Activity::~Activity() {
+    try {
+        logger.stopActivity(id);
+    } catch (...) {
+        ignoreException();
+    }
+}
+
 }
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index 677aa4dae..ca768d555 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -94,8 +94,7 @@ struct Activity
 
     Activity(const Activity & act) = delete;
 
-    ~Activity()
-    { logger.stopActivity(id); }
+    ~Activity();
 
     void progress(uint64_t done = 0, uint64_t expected = 0, uint64_t running = 0, uint64_t failed = 0) const
     { result(resProgress, done, expected, running, failed); }
-- 
GitLab