From bdea29f0f3910ef3a6a47bbe26710379713c2127 Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Fri, 20 Sep 2024 15:55:16 +0000 Subject: [PATCH] fix(engine): sync outputs before printing stats at shutdown Signed-off-by: Luca Guerra --- userspace/falco/app/actions/process_events.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/userspace/falco/app/actions/process_events.cpp b/userspace/falco/app/actions/process_events.cpp index 33059304326..98d793b79d2 100644 --- a/userspace/falco/app/actions/process_events.cpp +++ b/userspace/falco/app/actions/process_events.cpp @@ -585,6 +585,12 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s) } } + // By deleting s.outputs, we make sure that the engine will wait until + // regular output has been completely sent before printing stats, avoiding + // intermixed stats with output. + // Note that this will only work if this is the last reference held by the + // shared pointer. + s.outputs.reset(); s.engine->print_stats(); return res;