Skip to content

Commit

Permalink
GH-1639 Fix producer_plugin shutdown of read only threads to prevent …
Browse files Browse the repository at this point in the history
…SEGFAULT and deadlock.
  • Loading branch information
heifner committed Sep 18, 2023
1 parent 7a7aa58 commit 1368ecd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libraries/custom_appbase/include/eosio/chain/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class three_queue_executor {
else
return read_only_queue_.wrap( priority, --order_, std::forward<Function>( func));
}

void stop() {
read_only_queue_.stop();
read_write_queue_.stop();
read_exclusive_queue_.stop();
}

void clear() {
read_only_queue_.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class exec_pri_queue : public boost::asio::execution_context
{
public:

~exec_pri_queue() {
void stop() {
std::lock_guard g( mtx_ );
exiting_blocking_ = true;
cond_.notify_all();
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,10 @@ void producer_plugin::plugin_startup() {
void producer_plugin_impl::plugin_shutdown() {
boost::system::error_code ec;
_timer.cancel(ec);
boost::system::error_code ro_ec;
_ro_timer.cancel(ro_ec);
app().executor().stop();
_ro_thread_pool.stop();
_thread_pool.stop();
_unapplied_transactions.clear();

Expand Down

0 comments on commit 1368ecd

Please sign in to comment.