Skip to content

Commit c122ed4

Browse files
FedeDPpoiana
authored andcommitted
chore(plugins/container): make ASYNC cap resilient to multiple calls.
Static-storage variables are correctly checked. This can happend in 2 scenarios: * sinsp erratingly calls multiple times start async API (should be a bug but better safe than sorry) * Falco hot reload dry-run checks Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
1 parent e25a1f8 commit c122ed4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugins/container/src/caps/async/async.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ std::vector<std::string> my_plugin::get_async_event_sources()
2323
bool my_plugin::start_async_events(
2424
std::shared_ptr<falcosecurity::async_event_handler_factory> f)
2525
{
26+
// We are already started. This can happen:
27+
// * if `start_async_events` is called multiple times
28+
// * during Falco hot reload dry-run checks; in that scenario,
29+
// the same library object gets opened once again, thus a new `my_plugin`
30+
// instance is created,
31+
// and all static variables are shared. Just return true and do nothing.
32+
if(s_async_handler[ASYNC_HANDLER_DEFAULT] != nullptr)
33+
{
34+
return true;
35+
}
36+
2637
for(int i = 0; i < ASYNC_HANDLER_MAX; i++)
2738
{
2839
s_async_handler[i] = std::move(f->new_handler());

0 commit comments

Comments
 (0)