Skip to content

Commit 0cb7d76

Browse files
committed
Revert "libmpathutil: runner: use pthread_cleanup_push()"
This reverts commit b2811e7.
1 parent ca15f00 commit 0cb7d76

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

libmpathutil/runner.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)