fix deadlock

This commit is contained in:
Evan Almloff committed 2023-02-01 14:15:17 -06:00
1 parent 5eb4ca677d
commit 39a3db68bd
1 file changed
+12 -5
+12 -5
View File
@@ -1,4 +1,5 @@
use anymap::AnyMap; use anymap::AnyMap;
use core::panic;
use parking_lot::RwLock; use parking_lot::RwLock;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use std::any::{Any, TypeId}; use std::any::{Any, TypeId};
@@ -80,6 +81,7 @@ impl DirtyNodeStates {
let mut dirty = values.get_mut(&pass_id)?; let mut dirty = values.get_mut(&pass_id)?;
let node_id = dirty.pop()?; let node_id = dirty.pop()?;
if dirty.is_empty() { if dirty.is_empty() {
drop(dirty);
values.remove(&pass_id); values.remove(&pass_id);
} }
node_id node_id
@@ -99,12 +101,17 @@ impl DirtyNodeStates {
.iter() .iter()
.rev() .rev()
.find(|(_, values)| values.contains_key(&pass_id))?; .find(|(_, values)| values.contains_key(&pass_id))?;
let mut dirty = values.get_mut(&pass_id)?; let node_id = {
let node_id = dirty.pop()?; let mut dirty = values.get_mut(&pass_id)?;
if dirty.is_empty() { let node_id = dirty.pop()?;
values.remove(&pass_id); if dirty.is_empty() {
} drop(dirty);
values.remove(&pass_id);
}
node_id
};
if values.is_empty() { if values.is_empty() {
drop(dirty_read);
let mut dirty_write = self.dirty.write(); let mut dirty_write = self.dirty.write();
dirty_write.remove(&height); dirty_write.remove(&height);
} }