Browse Source

✨ feat: fix pid recycling (#8225)

xqyjlj 1 year ago
parent
commit
fa9b496b2a
1 changed files with 11 additions and 3 deletions
  1. 11 3
      components/lwp/lwp_pid.c

+ 11 - 3
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);