Skip to content

Commit

Permalink
fix: dead lock
Browse files Browse the repository at this point in the history
  • Loading branch information
wathenjiang committed Sep 20, 2023
1 parent e325825 commit a710434
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tokio/src/runtime/task/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ impl<S: 'static> OwnedTasks<S> {
self.closed.store(true, Ordering::Release);
for i in start..self.grain as usize + start {
loop {
let task = match self.lists[i & (self.grain - 1) as usize].lock().pop_back() {
let mut lock = self.lists[i & (self.grain - 1) as usize].lock();
let task = match lock.pop_back() {
Some(task) => {
self.count.fetch_sub(1, Ordering::Relaxed);
task
}
None => break,
};
drop(lock);
task.shutdown();
}
}
Expand Down

0 comments on commit a710434

Please sign in to comment.