Skip to content

[lwp][tid]add error log when tid depleted, and return correct errno when clone failed #9327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/lwp/lwp_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,7 @@ long _sys_clone(void *arg[])
rt_thread_t thread = RT_NULL;
rt_thread_t self = RT_NULL;
int tid = 0;
rt_err_t err;

unsigned long flags = 0;
void *user_stack = RT_NULL;
Expand Down Expand Up @@ -1935,6 +1936,9 @@ long _sys_clone(void *arg[])
rt_thread_startup(thread);
return (long)tid;
fail:
err = GET_ERRNO();
RT_ASSERT(err < 0);

lwp_tid_put(tid);
if (thread)
{
Expand All @@ -1944,7 +1948,7 @@ long _sys_clone(void *arg[])
{
lwp_ref_dec(lwp);
}
return GET_ERRNO();
return (long)err;
}

rt_weak long sys_clone(void *arg[])
Expand Down
6 changes: 6 additions & 0 deletions components/lwp/lwp_tid.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ int lwp_tid_get(void)
current_tid = tid;
}
lwp_mutex_release_safe(&tid_lock);

if (tid <= 0)
{
LOG_W("resource TID exhausted.");
}

return tid;
}

Expand Down
Loading