From e682a8e138c44e557c57a8dcf33555ad7790dd8c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Jul 2016 18:14:16 +0200 Subject: Fix assertion failure in ThreadPool::enqueue() --- src/libutil/thread-pool.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/libutil/thread-pool.cc') diff --git a/src/libutil/thread-pool.cc b/src/libutil/thread-pool.cc index 32363ecf0..696ecd6c3 100644 --- a/src/libutil/thread-pool.cc +++ b/src/libutil/thread-pool.cc @@ -36,7 +36,8 @@ ThreadPool::~ThreadPool() void ThreadPool::enqueue(const work_t & t) { auto state(state_.lock()); - assert(!state->quit); + if (state->quit) + throw ThreadPoolShutDown("cannot enqueue a work item while the thread pool is shutting down"); state->left.push(t); if (state->left.size() > state->workers.size() && state->workers.size() < maxThreads) state->workers.emplace_back(&ThreadPool::workerEntry, this); @@ -84,7 +85,8 @@ void ThreadPool::workerEntry() } catch (std::exception & e) { auto state(state_.lock()); if (state->exception) { - if (!dynamic_cast(&e)) + if (!dynamic_cast(&e) && + !dynamic_cast(&e)) printMsg(lvlError, format("error: %s") % e.what()); } else { state->exception = std::current_exception(); -- cgit v1.2.3