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
This commit is contained in:
moneromooo-monero 2020-02-12 14:00:16 +00:00
parent 760ecf2ac8
commit 09c8111c53
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -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();