Skip to content

Commit

Permalink
fix(userspace/engine): free formatters, if any
Browse files Browse the repository at this point in the history
Previously, formatters were freed by LUA code when re-opening outputs.
Since now, outputs are not controlling anymore the falco_formats class (see #1412), we just free formatters only if were already initialized.

That is needed when the engine restarts (see #1446).

By doing so, we also ensure that correct inspector instance is set to the formatter cache.

Signed-off-by: Leonardo Grasso <[email protected]>
  • Loading branch information
leogr committed Oct 15, 2020
1 parent 47fa7d5 commit c0f3b5a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions userspace/engine/formats.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2019 The Falco Authors.
Copyright (C) 2020 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,8 +44,10 @@ void falco_formats::init(sinsp *inspector,
s_json_include_output_property = json_include_output_property;
if(!s_formatters)
{
s_formatters = new sinsp_evt_formatter_cache(s_inspector);
delete(s_formatters);
s_formatters = NULL;
}
s_formatters = new sinsp_evt_formatter_cache(s_inspector);

luaL_openlib(ls, "formats", ll_falco, 0);
}
Expand Down

0 comments on commit c0f3b5a

Please sign in to comment.