Skip to content

HG examples: Possible data races #563

@ryancaicse

Description

@ryancaicse

Hi, should thread-shared static variable hg_progress_shutdown_flag be protected by locks?

hg_engine_finalize(void)
{
int ret;
/* tell progress thread to wrap things up */
hg_progress_shutdown_flag = 1;
/* wait for it to shutdown cleanly */
ret = pthread_join(hg_progress_tid, NULL);
assert(ret == 0);
(void) ret;
return;
}

static void *
hg_progress_fn(void *foo)
{
hg_return_t ret;
unsigned int actual_count;
(void) foo;
while (!hg_progress_shutdown_flag) {
do {
ret = HG_Trigger(hg_context, 0, 1, &actual_count);
} while (
(ret == HG_SUCCESS) && actual_count && !hg_progress_shutdown_flag);
if (!hg_progress_shutdown_flag)
HG_Progress(hg_context, 100);
}
return (NULL);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions