mirror of
https://github.com/Zygo/bees.git
synced 2025-05-18 13:55:44 +02:00
roots: don't deadlock while deleting a crawl thread
BeesRoots::crawl_state_erase may invoke BeesCrawl::~BeesCrawl, which will do a join on its crawl thread, which might be trying to lock BeesRoots::m_mutex, which is locked by crawl_state_erase at the time. Fix this by creating an extra reference to the BeesCrawl object, then releasing the lock on BeesRoots::m_mutex, then deleting the reference. The BeesCrawl object may still call methods on BeesRoots, but the only such method is BeesRoots::crawl_state_set_dirty, and that method has no dependency on the erased BeesCrawl shared_ptr. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
4604f5bc96
commit
4f9c2c0310
@ -154,8 +154,10 @@ BeesRoots::crawl_state_erase(const BeesCrawlState &bcs)
|
||||
|
||||
auto found = m_root_crawl_map.find(bcs.m_root);
|
||||
if (found != m_root_crawl_map.end()) {
|
||||
auto hold_this_until_unlocked = found->second;
|
||||
m_root_crawl_map.erase(found);
|
||||
m_crawl_dirty = true;
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user