diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 07c6953a3be..8d5ddb2cc68 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -3414,12 +3414,6 @@ namespace eosio { my->keepalive_timer->cancel(); } - if( my->acceptor ) { - boost::system::error_code ec; - my->acceptor->cancel( ec ); - my->acceptor->close( ec ); - } - { fc_ilog( logger, "close ${s} connections", ("s", my->connections.size()) ); std::lock_guard g( my->connections_mtx ); @@ -3433,6 +3427,13 @@ namespace eosio { if( my->thread_pool ) { my->thread_pool->stop(); } + + if( my->acceptor ) { + boost::system::error_code ec; + my->acceptor->cancel( ec ); + my->acceptor->close( ec ); + } + app().post( 0, [me = my](){} ); // keep my pointer alive until queue is drained fc_ilog( logger, "exit shutdown" ); }