diff --git a/core/app-template.cc b/core/app-template.cc index 2669e71ac8..eac2adb160 100644 --- a/core/app-template.cc +++ b/core/app-template.cc @@ -70,7 +70,9 @@ app_template::run(int ac, char ** av, std::function&& func) { engine().exit(1); } }); - return engine().run(); + auto exit_code = engine().run(); + smp::cleanup(); + return exit_code; } diff --git a/core/reactor.cc b/core/reactor.cc index 8014d227c4..c968a076bf 100644 --- a/core/reactor.cc +++ b/core/reactor.cc @@ -1266,6 +1266,10 @@ void smp::allocate_reactor() { reactor_holder.reset(local_engine); } +void smp::cleanup() { + smp::_threads = std::vector(); +} + void smp::configure(boost::program_options::variables_map configuration) { smp::count = 1; diff --git a/core/reactor.hh b/core/reactor.hh index 855add3a58..2ff3a97768 100644 --- a/core/reactor.hh +++ b/core/reactor.hh @@ -837,6 +837,7 @@ class smp { public: static boost::program_options::options_description get_options_description(); static void configure(boost::program_options::variables_map vm); + static void cleanup(); static void join_all(); static bool main_thread() { return std::this_thread::get_id() == _tmain; }