File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,10 +40,10 @@ struct runner_context {
4040 char __attribute__((aligned (sizeof (void * )))) data [];
4141};
4242
43- static void cleanup_context (void * arg )
43+ static void cleanup_context (struct runner_context * * prctx )
4444{
45+ struct runner_context * rctx = * prctx ;
4546 int st ;
46- struct runner_context * rctx = arg ;
4747
4848 if (!rctx ) {
4949 condlog (0 , "ERROR: %s: rctx is NULL" , __func__ );
@@ -82,9 +82,7 @@ static void *runner_thread(void *arg)
8282 * The cleanup function makes sure memory is freed if the thread is
8383 * cancelled (-fexceptions).
8484 */
85- struct runner_context * rctx = arg ;
86-
87- pthread_cleanup_push (cleanup_context , arg );
85+ struct runner_context * rctx __attribute__((cleanup (cleanup_context ))) = arg ;
8886
8987#ifdef RUNNER_START_DELAY_US
9088 /*
@@ -100,12 +98,10 @@ static void *runner_thread(void *arg)
10098#endif
10199
102100 st = uatomic_cmpxchg (& rctx -> status , RUNNER_IDLE , RUNNER_RUNNING );
101+ if (st != RUNNER_IDLE )
102+ return NULL ;
103103
104- /* Only run the function if we haven't been cancelled */
105- if (st == RUNNER_IDLE )
106- (* rctx -> func )(rctx -> data );
107-
108- pthread_cleanup_pop (1 );
104+ (* rctx -> func )(rctx -> data );
109105 return NULL ;
110106}
111107
You can’t perform that action at this time.
0 commit comments