From 6a3980bda51823ccf64b8a9867b50c2c6d4e40e3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 30 Sep 2024 16:52:04 -0500 Subject: [PATCH 1/2] Temporary fix for 1.0.x until we can get a proper fix in for the interaction of app io_context and plugin threads. --- plugins/state_history_plugin/state_history_plugin.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index df6b839a31..7f95debc38 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -380,6 +380,14 @@ void state_history_plugin_impl::plugin_shutdown() { accepted_block_connection.reset(); block_start_connection.reset(); thread_pool.stop(); + + // This is a temporary fix until https://github.com/AntelopeIO/spring/issues/842 can be worked. + // Drain the io_service of anything that could be referencing state_history_plugin + if (app().executor().get_io_service().stopped()) { + app().executor().get_io_service().restart(); + while (app().executor().get_io_service().poll()) + ; + } } void state_history_plugin::plugin_shutdown() { From a31949a3cddb725034154429b1ba09d8e7221fdf Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 1 Oct 2024 07:17:22 -0500 Subject: [PATCH 2/2] GH-822 Add in clear of executor --- plugins/state_history_plugin/state_history_plugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index 7f95debc38..8a65d7c0a8 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -387,6 +387,8 @@ void state_history_plugin_impl::plugin_shutdown() { app().executor().get_io_service().restart(); while (app().executor().get_io_service().poll()) ; + // clear priority queue of anything pushed by poll(), see application_base exec() + app().executor().clear(); } }