diff options
author | luigi1111 <luigi1111w@gmail.com> | 2020-09-03 12:25:59 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2020-09-03 12:25:59 -0500 |
commit | ee0b02d0dbdafebd28aa535baae086f8d481d191 (patch) | |
tree | 7c188abaf0956567f56a6c44cf3adf0b397823f6 /src/common/threadpool.cpp | |
parent | Merge pull request #6789 (diff) | |
parent | threadpool: guard against exceptions in jobs, and armour plating (diff) | |
download | monero-ee0b02d0dbdafebd28aa535baae086f8d481d191.tar.xz |
Merge pull request #6757
6a37da8 threadpool: guard against exceptions in jobs, and armour plating (moneromooo-monero)
Diffstat (limited to 'src/common/threadpool.cpp')
-rw-r--r-- | src/common/threadpool.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp index a1737778c..edc87fc48 100644 --- a/src/common/threadpool.cpp +++ b/src/common/threadpool.cpp @@ -120,7 +120,7 @@ threadpool::waiter::~waiter() catch (...) { /* ignore */ } try { - wait(NULL); + wait(); } catch (const std::exception &e) { @@ -128,12 +128,12 @@ threadpool::waiter::~waiter() } } -void threadpool::waiter::wait(threadpool *tpool) { - if (tpool) - tpool->run(true); +bool threadpool::waiter::wait() { + pool.run(true); boost::unique_lock<boost::mutex> lock(mt); while(num) cv.wait(lock); + return !error(); } void threadpool::waiter::inc() { @@ -166,7 +166,8 @@ void threadpool::run(bool flush) { lock.unlock(); ++depth; is_leaf = e.leaf; - e.f(); + try { e.f(); } + catch (const std::exception &ex) { e.wo->set_error(); try { MERROR("Exception in threadpool job: " << ex.what()); } catch (...) {} } --depth; is_leaf = false; |