diff --git a/runtime/src/main.c b/runtime/src/main.c index 2898ad6..10f6e8e 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -348,10 +348,10 @@ main(int argc, char **argv) runtime_allocate_available_cores(); runtime_configure(); runtime_initialize(); + software_interrupt_initialize(); listener_thread_initialize(); runtime_start_runtime_worker_threads(); - software_interrupt_initialize(); software_interrupt_arm_timer(); #ifdef LOG_MODULE_LOADING diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 0d75fa2..e0f5791 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -101,9 +101,6 @@ runtime_initialize(void) /* Configure Signals */ signal(SIGPIPE, SIG_IGN); signal(SIGTERM, runtime_cleanup); - /* These should only be unmasked by workers */ - software_interrupt_mask_signal(SIGUSR1); - software_interrupt_mask_signal(SIGALRM); http_parser_settings_initialize(); admissions_control_initialize(); diff --git a/runtime/src/sandbox_state.c b/runtime/src/sandbox_state.c index 7e404c9..08a4a59 100644 --- a/runtime/src/sandbox_state.c +++ b/runtime/src/sandbox_state.c @@ -7,9 +7,7 @@ #include "debuglog.h" #include "sandbox_state.h" -// TODO: Double check this const bool sandbox_state_is_terminal[SANDBOX_STATE_COUNT] = { - [SANDBOX_UNINITIALIZED] = false, [SANDBOX_ALLOCATED] = false, [SANDBOX_INITIALIZED] = true, [SANDBOX_SET_AS_RUNNABLE] = false, [SANDBOX_RUNNABLE] = true, [SANDBOX_SET_AS_RUNNING] = false, [SANDBOX_RUNNING] = true, [SANDBOX_SET_AS_BLOCKED] = false, [SANDBOX_BLOCKED] = true, diff --git a/runtime/src/software_interrupt.c b/runtime/src/software_interrupt.c index 01fe89a..befe800 100644 --- a/runtime/src/software_interrupt.c +++ b/runtime/src/software_interrupt.c @@ -25,8 +25,7 @@ * Process Globals * ******************/ -static const int software_interrupt_supported_signals[] = { SIGALRM, SIGUSR1 }; -static uint64_t software_interrupt_interval_duration_in_cycles; +static uint64_t software_interrupt_interval_duration_in_cycles; /****************** * Thread Globals * @@ -284,18 +283,18 @@ software_interrupt_initialize(void) signal_action.sa_flags = SA_SIGINFO | SA_RESTART; /* all threads created by the calling thread will have signal blocked */ - - // TODO: Unclear about this... + /* TODO: What does sa_mask do? I have to call software_interrupt_mask_signal below */ sigemptyset(&signal_action.sa_mask); - // sigaddset(&signal_action.sa_mask, SIGALRM); - // sigaddset(&signal_action.sa_mask, SIGUSR1); - - for (int i = 0; - i < (sizeof(software_interrupt_supported_signals) / sizeof(software_interrupt_supported_signals[0])); - i++) { - // TODO: Setup masks - int return_code = sigaction(software_interrupt_supported_signals[i], &signal_action, NULL); - if (return_code) { + sigaddset(&signal_action.sa_mask, SIGALRM); + sigaddset(&signal_action.sa_mask, SIGUSR1); + + const int supported_signals[] = { SIGALRM, SIGUSR1 }; + const size_t supported_signals_len = 2; + + for (int i = 0; i < supported_signals_len; i++) { + int signal = supported_signals[i]; + software_interrupt_mask_signal(signal); + if (sigaction(signal, &signal_action, NULL)) { perror("sigaction"); exit(1); }