Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Close acceptor after shutdown of thread pool so it is safe to access …
Browse files Browse the repository at this point in the history
…from application thread
  • Loading branch information
heifner committed Aug 16, 2019
1 parent f0b29aa commit 139252c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::shared_mutex> g( my->connections_mtx );
Expand All @@ -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" );
}
Expand Down

0 comments on commit 139252c

Please sign in to comment.