curds: Fix a deadlock with ETree.lookup_path()
Most functions lock the tree from the leaves up, but this was locking the tree from the root down. This was leading to frequent deadlocks. Let's fix this by only holding the tree_lock to look up each node, and release it ASAP instead of locking the entire tree. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
53a1e085d4
commit
426eeb0c97
|
@ -103,14 +103,9 @@ class ETree:
|
|||
return None
|
||||
if len(path) == 0:
|
||||
return self
|
||||
|
||||
with self.tree_lock:
|
||||
child = self.__nth_child__(path[0])
|
||||
if len(path) == 1:
|
||||
return child
|
||||
elif child:
|
||||
return child.lookup_path(path[1:])
|
||||
return None
|
||||
if (child := self.nth_child(path[0])) and len(path) > 1:
|
||||
child = child.lookup_path(path[1:])
|
||||
return child
|
||||
|
||||
def n_children(self):
|
||||
with self.tree_lock:
|
||||
|
|
Loading…
Reference in New Issue