summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxqyjlj <[email protected]>2023-11-06 13:22:27 +0800
committerGitHub <[email protected]>2023-11-06 13:22:27 +0800
commitfa9b496b2ad33d05871a0691b4a1bbc479b28dde (patch)
treecca59183a04cb7c683e0b9aac07d2edbf4f3100d
parentb51a3420b00502315e608dac0cb33917c235d277 (diff)
✨ feat: fix pid recycling (#8225)
-rw-r--r--components/lwp/lwp_pid.c14
1 files 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);