diff --git a/src/common/slurm_acct_gather.c b/src/common/slurm_acct_gather.c index e15cd414216e1688d4714648d2fa7f0f4500d7d7..8db8397e853f6d9db3d701789c26be67b870eb59 100644 --- a/src/common/slurm_acct_gather.c +++ b/src/common/slurm_acct_gather.c @@ -42,7 +42,8 @@ #include "src/common/slurm_strcasestr.h" #include "src/common/xstring.h" -bool acct_gather_suspended = false; +static bool acct_gather_suspended = false; +static pthread_mutex_t suspended_mutex = PTHREAD_MUTEX_INITIALIZER; static bool inited = 0; @@ -244,10 +245,23 @@ extern int acct_gather_check_acct_freq_task( extern void acct_gather_suspend_poll(void) { + slurm_mutex_lock(&suspended_mutex); acct_gather_suspended = true; + slurm_mutex_unlock(&suspended_mutex); } extern void acct_gather_resume_poll(void) { + slurm_mutex_lock(&suspended_mutex); acct_gather_suspended = false; + slurm_mutex_unlock(&suspended_mutex); +} + +extern bool acct_gather_suspend_test(void) +{ + bool rc; + slurm_mutex_lock(&suspended_mutex); + rc = acct_gather_suspended; + slurm_mutex_unlock(&suspended_mutex); + return rc; } diff --git a/src/common/slurm_acct_gather.h b/src/common/slurm_acct_gather.h index e6533a92a0148523160a393270639f5b933e6b55..eda1d90697e5a23510adb3b184082526bce19b17 100644 --- a/src/common/slurm_acct_gather.h +++ b/src/common/slurm_acct_gather.h @@ -57,8 +57,6 @@ #include "slurm_acct_gather_infiniband.h" #include "slurm_acct_gather_filesystem.h" -extern bool acct_gather_suspended; - extern int acct_gather_conf_init(void); extern int acct_gather_conf_destroy(void); @@ -69,5 +67,6 @@ extern int acct_gather_check_acct_freq_task( uint32_t job_mem_lim, char *acctg_freq); extern void acct_gather_suspend_poll(void); extern void acct_gather_resume_poll(void); +extern bool acct_gather_suspend_test(void); #endif diff --git a/src/common/slurm_acct_gather_profile.c b/src/common/slurm_acct_gather_profile.c index c016c0102d33f6632a78cdcb61c5e54dcbc34f42..949003d50c22120e7b0d615a60de93c7937d7097 100644 --- a/src/common/slurm_acct_gather_profile.c +++ b/src/common/slurm_acct_gather_profile.c @@ -147,7 +147,7 @@ static void *_timer_thread(void *args) now = time(NULL); for (i=0; i<PROFILE_CNT; i++) { - if (acct_gather_suspended) { + if (acct_gather_suspend_test()) { /* Handle suspended time as if it * didn't happen */ if (!acct_gather_profile_timer[i].freq)