Fix an issue with unchecked_map::~unchecked_map where the condition variable signal can be missed since the object mutex isn't acquired while setting stopped=true. Converts unchecked_map::stopped to a non-atomic bool since it needs a mutex anyway. (#3723)
This commit is contained in:
parent
c6ff231a00
commit
7ea11f8292
2 changed files with 4 additions and 2 deletions
|
@ -63,8 +63,10 @@ size_t nano::unchecked_map::count (nano::transaction const & transaction) const
|
|||
|
||||
void nano::unchecked_map::stop ()
|
||||
{
|
||||
if (!stopped.exchange (true))
|
||||
nano::unique_lock<nano::mutex> lock{ mutex };
|
||||
if (!stopped)
|
||||
{
|
||||
stopped = true;
|
||||
condition.notify_all (); // Notify flush (), run ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
std::deque<boost::variant<insert, query>> buffer;
|
||||
std::deque<boost::variant<insert, query>> back_buffer;
|
||||
bool writing_back_buffer{ false };
|
||||
std::atomic<bool> stopped{ false };
|
||||
bool stopped{ false };
|
||||
nano::condition_variable condition;
|
||||
nano::mutex mutex;
|
||||
std::thread thread;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue