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
|
* within the pthread_exit() and pthread_cancellation() logic
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* tls - The local storage info of the exiting thread
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
@ -184,7 +184,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||||
void pthread_cleanup_popall(void);
|
void pthread_cleanup_popall(FAR struct tls_info_s *tls);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef EXTERN
|
#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
|
* within the pthread_exit() and pthread_cancellation() logic
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* tls - The local storage info of the exiting thread
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* 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);
|
DEBUGASSERT(tls != NULL);
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/pthread.h>
|
#include <nuttx/pthread.h>
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
@ -54,7 +55,7 @@
|
|||||||
void pthread_exit(FAR void *exit_value)
|
void pthread_exit(FAR void *exit_value)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||||
pthread_cleanup_popall();
|
pthread_cleanup_popall(up_tls_info());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_TLS_NELEM > 0
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
#include <nuttx/pthread.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "task/task.h"
|
#include "task/task.h"
|
||||||
#include "pthread/pthread.h"
|
#include "pthread/pthread.h"
|
||||||
@ -86,6 +89,12 @@ int pthread_cancel(pthread_t thread)
|
|||||||
pthread_exit(PTHREAD_CANCELED);
|
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 */
|
/* Complete pending join operations */
|
||||||
|
|
||||||
pthread_completejoin((pid_t)thread, PTHREAD_CANCELED);
|
pthread_completejoin((pid_t)thread, PTHREAD_CANCELED);
|
||||||
|
Loading…
Reference in New Issue
Block a user