mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-12 19:36:42 +00:00
refactor(userspace/falco): make signal handlers thread-safe
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
parent
f2aba88a6c
commit
34ca78786a
@ -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;
|
||||
}
|
||||
|
@ -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<falco_configuration>();
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ limitations under the License.
|
||||
#include "app_cmdline_options.h"
|
||||
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
|
||||
namespace falco {
|
||||
namespace app {
|
||||
@ -61,9 +62,8 @@ private:
|
||||
state();
|
||||
virtual ~state();
|
||||
|
||||
bool restart;
|
||||
bool terminate;
|
||||
bool reopen_outputs;
|
||||
std::atomic<bool> restart;
|
||||
std::atomic<bool> terminate;
|
||||
|
||||
std::shared_ptr<falco_configuration> config;
|
||||
std::shared_ptr<falco_outputs> outputs;
|
||||
|
Loading…
Reference in New Issue
Block a user