diff --git a/userspace/falco/app_actions/process_events.cpp b/userspace/falco/app_actions/process_events.cpp index f29e4d07..a19f0c56 100644 --- a/userspace/falco/app_actions/process_events.cpp +++ b/userspace/falco/app_actions/process_events.cpp @@ -90,13 +90,8 @@ application::run_result application::do_inspect(syscall_evt_drop_mgr &sdropmgr, writer.handle(); - if(m_state->reopen_outputs) - { - m_state->outputs->reopen_outputs(); - m_state->reopen_outputs = false; - } - - if(m_state->terminate || m_state->restart) + if(m_state->terminate.load(std::memory_order_acquire) + || m_state->restart.load(std::memory_order_acquire)) { break; } diff --git a/userspace/falco/application.cpp b/userspace/falco/application.cpp index eff2ac08..7a88472e 100644 --- a/userspace/falco/application.cpp +++ b/userspace/falco/application.cpp @@ -41,7 +41,6 @@ application::run_result::~run_result() application::state::state() : restart(false), terminate(false), - reopen_outputs(false), enabled_sources({falco_common::syscall_source}) { config = std::make_shared(); @@ -67,15 +66,17 @@ void application::terminate() { if(m_state != nullptr) { - m_state->terminate = true; + m_state->terminate.store(true, std::memory_order_release); } } void application::reopen_outputs() { - if(m_state != nullptr) + if(m_state != nullptr && m_state->outputs != nullptr) { - m_state->reopen_outputs = true; + // note: it is ok to do this inside the signal handler because + // in the current falco_outputs implementation this is non-blocking + m_state->outputs->reopen_outputs(); } } @@ -83,7 +84,7 @@ void application::restart() { if(m_state != nullptr) { - m_state->restart = true; + m_state->restart.store(true, std::memory_order_release); } } diff --git a/userspace/falco/application.h b/userspace/falco/application.h index 22b06cb1..c6ee5ff1 100644 --- a/userspace/falco/application.h +++ b/userspace/falco/application.h @@ -25,6 +25,7 @@ limitations under the License. #include "app_cmdline_options.h" #include +#include namespace falco { namespace app { @@ -61,9 +62,8 @@ private: state(); virtual ~state(); - bool restart; - bool terminate; - bool reopen_outputs; + std::atomic restart; + std::atomic terminate; std::shared_ptr config; std::shared_ptr outputs;