From fa9b496b2ad33d05871a0691b4a1bbc479b28dde Mon Sep 17 00:00:00 2001 From: xqyjlj Date: Mon, 6 Nov 2023 13:22:27 +0800 Subject: ✨ feat: fix pid recycling (#8225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/lwp/lwp_pid.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/lwp/lwp_pid.c b/components/lwp/lwp_pid.c index e26dfe2017..2b1a342c67 100644 --- a/components/lwp/lwp_pid.c +++ b/components/lwp/lwp_pid.c @@ -1308,9 +1308,17 @@ static void _resr_cleanup(struct rt_lwp *lwp) /** @note safe since the slist node is release */ LWP_UNLOCK(lwp); LWP_LOCK(child); - child->sibling = RT_NULL; - /* info: this may cause an orphan lwp */ - child->parent = RT_NULL; + if (child->terminated) + { + lwp_pid_put(child); + } + else + { + child->sibling = RT_NULL; + /* info: this may cause an orphan lwp */ + child->parent = RT_NULL; + } + LWP_UNLOCK(child); lwp_ref_dec(child); lwp_ref_dec(lwp); -- cgit v1.3.1