sched: Mark pthread as non-cancelable to avoid additional calls to pthread_exit()

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2022-02-18 15:12:41 +08:00 committed by Petro Karashchenko
parent 4de3ec646e
commit f452dd7ab4
2 changed files with 9 additions and 11 deletions

View File

@ -54,6 +54,15 @@
void pthread_exit(FAR void *exit_value)
{
/* Mark the pthread as non-cancelable to avoid additional calls to
* pthread_exit() due to any cancellation point logic that might get
* kicked off by actions taken during pthread_exit processing.
*/
#ifdef CONFIG_CANCELLATION_POINTS
task_setcancelstate(TASK_CANCEL_DISABLE, NULL);
#endif
#ifdef CONFIG_PTHREAD_CLEANUP
pthread_cleanup_popall(up_tls_info());
#endif

View File

@ -78,17 +78,6 @@ void nx_pthread_exit(FAR void *exit_value)
nxsig_procmask(SIG_SETMASK, &set, NULL);
#ifdef CONFIG_CANCELLATION_POINTS
/* Mark the pthread as non-cancelable to avoid additional calls to
* pthread_exit() due to any cancellation point logic that might get
* kicked off by actions taken during pthread_exit processing.
*/
tcb->flags |= TCB_FLAG_NONCANCELABLE;
tcb->flags &= ~TCB_FLAG_CANCEL_PENDING;
tcb->cpcount = 0;
#endif
/* Complete pending join operations */
status = pthread_completejoin(getpid(), exit_value);