From a710434d41b29836df2e872f0a246b2c080d093b Mon Sep 17 00:00:00 2001 From: Weijia Jiang Date: Thu, 21 Sep 2023 00:56:10 +0800 Subject: [PATCH] fix: dead lock --- tokio/src/runtime/task/list.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index 7736abd331a..905f5508e01 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -159,13 +159,15 @@ impl OwnedTasks { 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(); } }