Skip to content

Commit

Permalink
[lwp] Fix a bug when lwp_pid_get_locked cannot find pid.
Browse files Browse the repository at this point in the history
  • Loading branch information
yby-oy committed Oct 30, 2023
1 parent 7066761 commit dc24578
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions components/lwp/lwp_pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ static pid_t lwp_pid_get_locked(void)
{
struct lwp_avl_struct *p;
pid_t pid = 0;
int head_recover_flag = 0;

p = lwp_pid_free_head;
if (p)
{
lwp_pid_free_head = (struct lwp_avl_struct *)p->avl_right;
head_recover_flag = 1;
}
else if (lwp_pid_ary_alloced < RT_LWP_MAX_NR)
{
Expand Down Expand Up @@ -115,9 +117,22 @@ static pid_t lwp_pid_get_locked(void)
}
}
}
p->avl_key = pid;
lwp_avl_insert(p, &lwp_pid_root);
current_pid = pid;

if (found_noused == 1)
{
p->avl_key = pid;
lwp_avl_insert(p, &lwp_pid_root);
current_pid = pid;
}
else
{
pid = 0;
if (head_recover_flag == 1)
{
/* recover lwp_pid_free_head */
lwp_pid_free_head = p;
}
}
}
return pid;
}
Expand Down

0 comments on commit dc24578

Please sign in to comment.