aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-10-02 08:39:47 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-10-02 17:28:44 +0000
commite5108a294a7d4fd923665e059a6eb90b0ab5a337 (patch)
tree4069f097660a988018796bcfb90003aca7577887 /src
parentMerge pull request #4333 (diff)
downloadmonero-e5108a294a7d4fd923665e059a6eb90b0ab5a337.tar.xz
Catch more exceptions in dtors
Misc coverity reports
Diffstat (limited to 'src')
-rw-r--r--src/common/threadpool.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp
index 5ea04a353..37825e31d 100644
--- a/src/common/threadpool.cpp
+++ b/src/common/threadpool.cpp
@@ -51,11 +51,19 @@ threadpool::threadpool(unsigned int max_threads) : running(true), active(0) {
}
threadpool::~threadpool() {
+ try
{
const boost::unique_lock<boost::mutex> lock(mutex);
running = false;
has_work.notify_all();
}
+ catch (...)
+ {
+ // if the lock throws, we're just do it without a lock and hope,
+ // since the alternative is terminate
+ running = false;
+ has_work.notify_all();
+ }
for (size_t i = 0; i<threads.size(); i++) {
try { threads[i].join(); }
catch (...) { /* ignore */ }
@@ -91,11 +99,13 @@ unsigned int threadpool::get_max_concurrency() const {
threadpool::waiter::~waiter()
{
+ try
{
boost::unique_lock<boost::mutex> lock(mt);
if (num)
MERROR("wait should have been called before waiter dtor - waiting now");
}
+ catch (...) { /* ignore */ }
try
{
wait(NULL);