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

add error log when tid depleted, and return correct errno when clone failed
This commit is contained in:
zms123456 2024-08-23 05:52:45 +08:00 committed by GitHub
parent fd31965c3c
commit 9d95ad9b8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -1832,6 +1832,7 @@ long _sys_clone(void *arg[])
rt_thread_t thread = RT_NULL; rt_thread_t thread = RT_NULL;
rt_thread_t self = RT_NULL; rt_thread_t self = RT_NULL;
int tid = 0; int tid = 0;
rt_err_t err;
unsigned long flags = 0; unsigned long flags = 0;
void *user_stack = RT_NULL; void *user_stack = RT_NULL;
@ -1935,6 +1936,9 @@ long _sys_clone(void *arg[])
rt_thread_startup(thread); rt_thread_startup(thread);
return (long)tid; return (long)tid;
fail: fail:
err = GET_ERRNO();
RT_ASSERT(err < 0);
lwp_tid_put(tid); lwp_tid_put(tid);
if (thread) if (thread)
{ {
@ -1944,7 +1948,7 @@ fail:
{ {
lwp_ref_dec(lwp); lwp_ref_dec(lwp);
} }
return GET_ERRNO(); return (long)err;
} }
rt_weak long sys_clone(void *arg[]) rt_weak long sys_clone(void *arg[])

View File

@ -88,6 +88,12 @@ int lwp_tid_get(void)
current_tid = tid; current_tid = tid;
} }
lwp_mutex_release_safe(&tid_lock); lwp_mutex_release_safe(&tid_lock);
if (tid <= 0)
{
LOG_W("resource TID exhausted.");
}
return tid; return tid;
} }