fix(userspace/engine): free formatters, if any

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 <me@leonardograsso.com>
This commit is contained in:
Leonardo Grasso
2020-10-15 19:31:34 +02:00
committed by poiana
parent 61bfd5a158
commit cebec11552

View File

@@ -44,8 +44,9 @@ 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 = new sinsp_evt_formatter_cache(s_inspector);
luaL_openlib(ls, "formats", ll_falco, 0);
}