From e6b4c77c05082b3b041dae783b2c7a613352eb11 Mon Sep 17 00:00:00 2001 From: LoremKang Date: Tue, 22 Oct 2019 14:58:48 +0800 Subject: [PATCH] solve a potential unwrap error. deadlock when child lock first. --- kernel/src/ipc/semary.rs | 3 ++- user | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/src/ipc/semary.rs b/kernel/src/ipc/semary.rs index 6770bf8c..178b2f61 100644 --- a/kernel/src/ipc/semary.rs +++ b/kernel/src/ipc/semary.rs @@ -61,7 +61,8 @@ pub fn new_semary(key: usize, nsems: usize, semflg: usize) -> Arc { let mut key2sem_table = KEY2SEM.write(); let mut sem_array_ref: Arc; - if key2sem_table.get(&key).is_none() { + let mut key_sem_array_ref = key2sem_table.get(&key); + if (key_sem_array_ref.is_none() || key_sem_array_ref.unwrap().upgrade().is_none()) { let mut semaphores: Vec = Vec::new(); for i in 0..nsems { semaphores.push(Semaphore::new(0)); diff --git a/user b/user index 11baf015..746114ac 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit 11baf01577e0ca87ef88e6f1f95d2192e43e5d58 +Subproject commit 746114ac65b255ba7bdffba0445a162e767e0a6f