From db46ec83a224f2992cc577bdf3fd0187eb4ab973 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Wed, 8 Jun 2016 13:51:16 -0700 Subject: [PATCH] Move some logic to avoid race condition reported by helgrind --- src/common/slurm_acct_gather_profile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/slurm_acct_gather_profile.c b/src/common/slurm_acct_gather_profile.c index cb19eac3deb..3d576bd3b4b 100644 --- a/src/common/slurm_acct_gather_profile.c +++ b/src/common/slurm_acct_gather_profile.c @@ -170,6 +170,8 @@ static void *_timer_thread(void *args) if (!acct_gather_profile_timer[i].freq || (diff < acct_gather_profile_timer[i].freq)) continue; + if (!acct_gather_profile_test()) + break; /* Shutting down */ debug2("profile signalling type %s", acct_gather_profile_type_t_name(i)); @@ -188,6 +190,10 @@ static void *_timer_thread(void *args) usleep(USLEEP_TIME - DELTA_TIMER); } + for (i=0; i < PROFILE_CNT; i++) { + pthread_cond_destroy(&acct_gather_profile_timer[i].notify); + } + return NULL; } @@ -523,8 +529,7 @@ extern void acct_gather_profile_endpoll(void) slurm_mutex_lock(&acct_gather_profile_timer[i].notify_mutex); pthread_cond_signal(&acct_gather_profile_timer[i].notify); slurm_mutex_unlock(&acct_gather_profile_timer[i].notify_mutex); - pthread_cond_destroy(&acct_gather_profile_timer[i].notify); - acct_gather_profile_timer[i].freq = 0; + switch (i) { case PROFILE_ENERGY: break; -- GitLab