diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-10-15 13:37:18 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-10-15 13:37:18 +0200 |
commit | 5ccd3d32b41c5ae2f1fcd9d3a2526a233c8f70f0 (patch) | |
tree | c4901428d67d7895662cfbbc370d56673d62eadd /src | |
parent | Merge pull request #4481 (diff) | |
parent | epee: initialize a few data members where it seems to be appropriate (diff) | |
download | monero-5ccd3d32b41c5ae2f1fcd9d3a2526a233c8f70f0.tar.xz |
Merge pull request #4489
00901e9c epee: initialize a few data members where it seems to be appropriate (moneromooo-monero)
144a6c32 abstract_tcp_server2: move m_period to subclass (moneromooo-monero)
758d7684 connection_basic: remove unused floating time start time (moneromooo-monero)
e5108a29 Catch more exceptions in dtors (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/common/threadpool.cpp | 10 |
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); |