pthread: Call cleanup callback while asyncrhonous cancel
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
c0a0de97ce
commit
8bf7f94d39
@ -176,7 +176,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
|
||||
* within the pthread_exit() and pthread_cancellation() logic
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
* tls - The local storage info of the exiting thread
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
@ -184,7 +184,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||
void pthread_cleanup_popall(void);
|
||||
void pthread_cleanup_popall(FAR struct tls_info_s *tls);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
@ -172,17 +172,15 @@ void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
|
||||
* within the pthread_exit() and pthread_cancellation() logic
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
* tls - The local storage info of the exiting thread
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void pthread_cleanup_popall(void)
|
||||
void pthread_cleanup_popall(FAR struct tls_info_s *tls)
|
||||
{
|
||||
FAR struct tls_info_s *tls = up_tls_info();
|
||||
|
||||
DEBUGASSERT(tls != NULL);
|
||||
|
||||
sched_lock();
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <debug.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/pthread.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
@ -54,7 +55,7 @@
|
||||
void pthread_exit(FAR void *exit_value)
|
||||
{
|
||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||
pthread_cleanup_popall();
|
||||
pthread_cleanup_popall(up_tls_info());
|
||||
#endif
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
|
@ -30,6 +30,9 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/tls.h>
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "task/task.h"
|
||||
#include "pthread/pthread.h"
|
||||
@ -86,6 +89,12 @@ int pthread_cancel(pthread_t thread)
|
||||
pthread_exit(PTHREAD_CANCELED);
|
||||
}
|
||||
|
||||
/* Refer to up_tls_info() */
|
||||
|
||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||
pthread_cleanup_popall(tcb->stack_alloc_ptr);
|
||||
#endif
|
||||
|
||||
/* Complete pending join operations */
|
||||
|
||||
pthread_completejoin((pid_t)thread, PTHREAD_CANCELED);
|
||||
|
Loading…
Reference in New Issue
Block a user