Skip to content
Snippets Groups Projects
Commit 127ac190 authored by Morris Jette's avatar Morris Jette
Browse files

Wrap variable with mutex

Valgrind's drd tool reported a race condition on a variable, so
mutex was added to wrap it. The chances of this causing a problem
are nill, but this makes it zero.
parent 641c38e1
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
#include "src/common/slurm_strcasestr.h" #include "src/common/slurm_strcasestr.h"
#include "src/common/xstring.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; static bool inited = 0;
...@@ -244,10 +245,23 @@ extern int acct_gather_check_acct_freq_task( ...@@ -244,10 +245,23 @@ extern int acct_gather_check_acct_freq_task(
extern void acct_gather_suspend_poll(void) extern void acct_gather_suspend_poll(void)
{ {
slurm_mutex_lock(&suspended_mutex);
acct_gather_suspended = true; acct_gather_suspended = true;
slurm_mutex_unlock(&suspended_mutex);
} }
extern void acct_gather_resume_poll(void) extern void acct_gather_resume_poll(void)
{ {
slurm_mutex_lock(&suspended_mutex);
acct_gather_suspended = false; 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;
} }
...@@ -57,8 +57,6 @@ ...@@ -57,8 +57,6 @@
#include "slurm_acct_gather_infiniband.h" #include "slurm_acct_gather_infiniband.h"
#include "slurm_acct_gather_filesystem.h" #include "slurm_acct_gather_filesystem.h"
extern bool acct_gather_suspended;
extern int acct_gather_conf_init(void); extern int acct_gather_conf_init(void);
extern int acct_gather_conf_destroy(void); extern int acct_gather_conf_destroy(void);
...@@ -69,5 +67,6 @@ extern int acct_gather_check_acct_freq_task( ...@@ -69,5 +67,6 @@ extern int acct_gather_check_acct_freq_task(
uint32_t job_mem_lim, char *acctg_freq); uint32_t job_mem_lim, char *acctg_freq);
extern void acct_gather_suspend_poll(void); extern void acct_gather_suspend_poll(void);
extern void acct_gather_resume_poll(void); extern void acct_gather_resume_poll(void);
extern bool acct_gather_suspend_test(void);
#endif #endif
...@@ -147,7 +147,7 @@ static void *_timer_thread(void *args) ...@@ -147,7 +147,7 @@ static void *_timer_thread(void *args)
now = time(NULL); now = time(NULL);
for (i=0; i<PROFILE_CNT; i++) { for (i=0; i<PROFILE_CNT; i++) {
if (acct_gather_suspended) { if (acct_gather_suspend_test()) {
/* Handle suspended time as if it /* Handle suspended time as if it
* didn't happen */ * didn't happen */
if (!acct_gather_profile_timer[i].freq) if (!acct_gather_profile_timer[i].freq)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment