Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/container/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# project metadata
project(
container
VERSION 0.2.0
VERSION 0.2.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump to 0.2.1.

DESCRIPTION "Falco container metadata enrichment Plugin"
LANGUAGES CXX)

Expand Down
22 changes: 16 additions & 6 deletions plugins/container/src/caps/async/async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

std::unique_ptr<falcosecurity::async_event_handler>
s_async_handler[ASYNC_HANDLER_MAX];
static void *s_async_ctx;

std::vector<std::string> my_plugin::get_async_events()
{
Expand All @@ -24,6 +23,17 @@ std::vector<std::string> my_plugin::get_async_event_sources()
bool my_plugin::start_async_events(
std::shared_ptr<falcosecurity::async_event_handler_factory> f)
{
// We are already started. This can happen:
// * if `start_async_events` is called multiple times
// * during Falco hot reload dry-run checks; in that scenario,
// the same library object gets opened once again, thus a new `my_plugin`
// instance is created,
// and all static variables are shared. Just return true and do nothing.
Comment on lines +26 to +31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is relevant comment.

if(s_async_handler[ASYNC_HANDLER_DEFAULT] != nullptr)
{
return true;
}

for(int i = 0; i < ASYNC_HANDLER_MAX; i++)
{
s_async_handler[i] = std::move(f->new_handler());
Expand All @@ -34,7 +44,7 @@ bool my_plugin::start_async_events(
falcosecurity::_internal::SS_PLUGIN_LOG_SEV_DEBUG);
nlohmann::json j(m_cfg);
const char *enabled_engines = nullptr;
s_async_ctx = StartWorker(generate_async_event<ASYNC_HANDLER_GO_WORKER>,
m_async_ctx = StartWorker(generate_async_event<ASYNC_HANDLER_GO_WORKER>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s_async_ctx (static) -> m_async_ctx (member of my_plugin class).

j.dump().c_str(), &enabled_engines);
m_logger.log(fmt::format("attached engine sockets: {}", enabled_engines),
falcosecurity::_internal::SS_PLUGIN_LOG_SEV_DEBUG);
Expand All @@ -48,7 +58,7 @@ bool my_plugin::start_async_events(
falcosecurity::_internal::SS_PLUGIN_LOG_SEV_TRACE);
}

return s_async_ctx != nullptr;
return m_async_ctx != nullptr;
}

// We need this API to stop the async thread when the
Expand All @@ -57,11 +67,11 @@ bool my_plugin::stop_async_events() noexcept
{
m_logger.log("stopping async go-worker",
falcosecurity::_internal::SS_PLUGIN_LOG_SEV_DEBUG);
if(s_async_ctx != nullptr)
if(m_async_ctx != nullptr)
{
// Implemented by GO worker.go
StopWorker(s_async_ctx);
s_async_ctx = nullptr;
StopWorker(m_async_ctx);
m_async_ctx = nullptr;

for(int i = 0; i < ASYNC_HANDLER_MAX; i++)
{
Expand Down
2 changes: 2 additions & 0 deletions plugins/container/src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class my_plugin

falcosecurity::logger m_logger;

void* m_async_ctx = nullptr;

// Last error of the plugin
std::string m_lasterr;
// Accessor to the thread table
Expand Down
Loading