Skip to content

Commit 1183f68

Browse files
committed
Fix a race between setting the signal handlers and marking hal_ready().
1 parent 519ba61 commit 1183f68

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/hal/user_comps/mb2hal/mb2hal.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ int main(int argc, char **argv)
8181
ERR(gbl.init_dbg, "Unable to create HAL pins");
8282
goto QUIT_CLEANUP;
8383
}
84-
hal_ready(gbl.hal_mod_id);
85-
OK(gbl.init_dbg, "HAL components created OK");
86-
87-
gbl.quit_flag = 0; //tell the threads to quit (SIGTERM o SIGQUIT) (unloadusr mb2hal).
84+
gbl.quit_flag = 0; //tell the threads to quit (SIGTERM or SIGINT) (unloadusr mb2hal).
8885
signal(SIGINT, quit_signal);
8986
//unloadusr and unload commands of halrun
9087
signal(SIGTERM, quit_signal);
9188

89+
hal_ready(gbl.hal_mod_id);
90+
OK(gbl.init_dbg, "HAL components created OK");
91+
9292
/* Each link has it's own thread */
9393
pthread_attr_init(&thrd_attr);
9494
for (counter = 0; counter < gbl.tot_mb_links; counter++) {
@@ -149,7 +149,7 @@ void *link_loop_and_logic(void *thrd_link_num)
149149

150150
for (tx_counter = 0; tx_counter < gbl.tot_mb_tx; tx_counter++) {
151151

152-
if (gbl.quit_flag != 0) { //tell the threads to quit (SIGTERM o SGIQUIT) (unloadusr mb2hal).
152+
if (gbl.quit_flag != 0) {
153153
return NULL;
154154
}
155155

@@ -225,7 +225,7 @@ void *link_loop_and_logic(void *thrd_link_num)
225225
break;
226226
}
227227

228-
if (gbl.quit_flag != 0) { //tell the threads to quit (SIGTERM o SGIQUIT) (unloadusr mb2hal).
228+
if (gbl.quit_flag != 0) {
229229
return NULL;
230230
}
231231

@@ -441,7 +441,7 @@ void quit_signal(int signal)
441441
{
442442
char *fnct_name = "quit_signal";
443443

444-
gbl.quit_flag = 1; //tell the threads to quit (SIGTERM o SIGQUIT) (unloadusr mb2hal).
444+
gbl.quit_flag = 1; //tell the threads to quit (SIGTERM or SIGINT) (unloadusr mb2hal).
445445
DBG(gbl.init_dbg, "signal [%d] received", signal);
446446
}
447447

0 commit comments

Comments
 (0)