Commit 604d52a4 authored by luis_pereira87's avatar luis_pereira87 Committed by Robert Schmidt

Replace sleep by mutex in itti_wait_tasks_end()

parent c4a657cc
...@@ -438,23 +438,24 @@ extern "C" { ...@@ -438,23 +438,24 @@ extern "C" {
void itti_send_terminate_message(task_id_t task_id) { void itti_send_terminate_message(task_id_t task_id) {
} }
static volatile bool shutting_down; pthread_mutex_t signal_mutex;
static void catch_sigterm(int) { static void catch_sigterm(int) {
static const char msg[] = "\n** Caught SIGTERM, shutting down\n"; static const char msg[] = "\n** Caught SIGTERM, shutting down\n";
__attribute__((unused)) __attribute__((unused))
int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1); int unused = write(STDOUT_FILENO, msg, sizeof(msg) - 1);
shutting_down = true; pthread_mutex_unlock(&signal_mutex);
} }
void itti_wait_tasks_end(void) { void itti_wait_tasks_end(void) {
shutting_down = false;
pthread_mutex_init(&signal_mutex, NULL);
pthread_mutex_lock(&signal_mutex);
signal(SIGTERM, catch_sigterm); signal(SIGTERM, catch_sigterm);
//signal(SIGINT, catch_sigterm); signal(SIGINT, catch_sigterm);
while (! shutting_down)
{ pthread_mutex_lock(&signal_mutex);
sleep(24 * 3600);
}
} }
void itti_update_lte_time(uint32_t frame, uint8_t slot) {} void itti_update_lte_time(uint32_t frame, uint8_t slot) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment