diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-11-10 12:58:19 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-11-10 12:58:49 +0000 |
commit | 27522aaa124a4a84091c3afaa85898dea2251c10 (patch) | |
tree | f20944731fdfedeca2be43a0cc5e91dff5930a26 /src/common/threadpool.h | |
parent | Merge pull request #6088 (diff) | |
download | monero-27522aaa124a4a84091c3afaa85898dea2251c10.tar.xz |
core_tests: reset thread pool between tests
Avoids a DB error (leading to an assert) where a thread uses
a read txn previously created with an environment that was
since closed and reopened. While this usually works since
BlockchainLMDB renews txns if it detects the environment has
changed, this will not work if objects end up being allocated
at the same address as the previous instance, leading to stale
data usage.
Thanks hyc for the LMDB debugging.
Diffstat (limited to '')
-rw-r--r-- | src/common/threadpool.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/threadpool.h b/src/common/threadpool.h index 5e490ee7d..a49d0e14f 100644 --- a/src/common/threadpool.h +++ b/src/common/threadpool.h @@ -69,12 +69,17 @@ public: // task to finish. void submit(waiter *waiter, std::function<void()> f, bool leaf = false); + // destroy and recreate threads + void recycle(); + unsigned int get_max_concurrency() const; ~threadpool(); private: threadpool(unsigned int max_threads = 0); + void destroy(); + void create(unsigned int max_threads); typedef struct entry { waiter *wo; std::function<void()> f; |