Skip to content

Commit f3397b0

Browse files
committed
fix deadlock
1 parent 5095c09 commit f3397b0

File tree

1 file changed

+17
-7
lines changed
  • crates/torii/task-network/src

1 file changed

+17
-7
lines changed

crates/torii/task-network/src/lib.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,24 @@ mod tests {
239239

240240
// Record execution state
241241
{
242-
let current = currently_executing.lock().await;
243-
let mut executed = executed_levels.lock().await;
244-
executed.push((id, current.clone()));
242+
// First, get the current executing tasks
243+
let current_executing = {
244+
let current = currently_executing.lock().await;
245+
current.clone() // Clone the data so we can release the lock
246+
};
245247

246-
// Remove from currently executing
247-
let mut current = currently_executing.lock().await;
248-
if let Some(pos) = current.iter().position(|&x| x == id) {
249-
current.remove(pos);
248+
// Now update the executed_levels with the captured state
249+
{
250+
let mut executed = executed_levels.lock().await;
251+
executed.push((id, current_executing));
252+
}
253+
254+
// Finally, remove this task from currently executing
255+
{
256+
let mut current = currently_executing.lock().await;
257+
if let Some(pos) = current.iter().position(|&x| x == id) {
258+
current.remove(pos);
259+
}
250260
}
251261
}
252262

0 commit comments

Comments
 (0)