threadpool: lock mutex in create

In some contrived case, it might theoretically be the case that
destroy is called from another thread, which would modify the
threads array from two threads.

Coverity 208372
pull/241/head
moneromooo-monero 4 years ago
parent 760ecf2ac8
commit 09c8111c53
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

@ -71,6 +71,7 @@ void threadpool::recycle() {
}
void threadpool::create(unsigned int max_threads) {
const boost::unique_lock<boost::mutex> lock(mutex);
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);
max = max_threads ? max_threads : tools::get_max_concurrency();

Loading…
Cancel
Save