Skip to content

Commit

Permalink
Merge pull request #517 from lf-lang/avoid-double-join
Browse files Browse the repository at this point in the history
Avoid a double join on the sensor_simulator output thread
  • Loading branch information
erlingrj authored Feb 11, 2025
2 parents 141dee7 + d66eb3b commit 8072355
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions util/sensor_simulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,16 @@ void end_sensor_simulator() {
lf_register_print_function(NULL, -1);
_lf_sensor_post_message(_lf_sensor_close_windows, NULL);

void* thread_return;
lf_thread_join(_lf_sensor.output_thread_id, &thread_return);
// Join thread, if it was created and it was not already joined.
if (_lf_sensor.thread_created > 0) {
void* thread_return;
lf_thread_join(_lf_sensor.output_thread_id, &thread_return);
_lf_sensor.thread_created = 0;
}

// Timeout mode should result in the input thread exiting on its own.
// pthread_kill(_lf_sensor.input_thread_id, SIGINT);

_lf_sensor.thread_created = 0;
if (_lf_sensor.log_file != NULL) {
fclose(_lf_sensor.log_file);
}
Expand Down

0 comments on commit 8072355

Please sign in to comment.