Skip to content

Commit 9d95ad9

Browse files
authored
[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
1 parent fd31965 commit 9d95ad9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

components/lwp/lwp_syscall.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,7 @@ long _sys_clone(void *arg[])
18321832
rt_thread_t thread = RT_NULL;
18331833
rt_thread_t self = RT_NULL;
18341834
int tid = 0;
1835+
rt_err_t err;
18351836

18361837
unsigned long flags = 0;
18371838
void *user_stack = RT_NULL;
@@ -1935,6 +1936,9 @@ long _sys_clone(void *arg[])
19351936
rt_thread_startup(thread);
19361937
return (long)tid;
19371938
fail:
1939+
err = GET_ERRNO();
1940+
RT_ASSERT(err < 0);
1941+
19381942
lwp_tid_put(tid);
19391943
if (thread)
19401944
{
@@ -1944,7 +1948,7 @@ long _sys_clone(void *arg[])
19441948
{
19451949
lwp_ref_dec(lwp);
19461950
}
1947-
return GET_ERRNO();
1951+
return (long)err;
19481952
}
19491953

19501954
rt_weak long sys_clone(void *arg[])

components/lwp/lwp_tid.c

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ int lwp_tid_get(void)
8888
current_tid = tid;
8989
}
9090
lwp_mutex_release_safe(&tid_lock);
91+
92+
if (tid <= 0)
93+
{
94+
LOG_W("resource TID exhausted.");
95+
}
96+
9197
return tid;
9298
}
9399

0 commit comments

Comments
 (0)