diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index b35b38a0da8..b563a36294a 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -3022,6 +3022,8 @@ namespace eosio { } void net_plugin::plugin_startup() { + handle_sighup(); + try { my->producer_plug = app().find_plugin(); // currently thread_pool only used for server_ioc @@ -3056,17 +3058,13 @@ namespace eosio { } } - my->keepalive_timer.reset( new boost::asio::steady_timer( my->thread_pool->get_executor() ) ); - my->ticker(); - if( my->acceptor ) { my->acceptor->open(my->listen_endpoint.protocol()); my->acceptor->set_option(tcp::acceptor::reuse_address(true)); try { my->acceptor->bind(my->listen_endpoint); } catch (const std::exception& e) { - fc_elog( logger, "net_plugin::plugin_startup failed to bind to port ${port}", - ("port", my->listen_endpoint.port())); + elog( "net_plugin::plugin_startup failed to bind to port ${port}", ("port", my->listen_endpoint.port())); throw e; } my->acceptor->listen(); @@ -3078,6 +3076,9 @@ namespace eosio { cc.accepted_block.connect( boost::bind(&net_plugin_impl::accepted_block, my.get(), _1)); } + my->keepalive_timer.reset( new boost::asio::steady_timer( my->thread_pool->get_executor() ) ); + my->ticker(); + my->incoming_transaction_ack_subscription = app().get_channel().subscribe(boost::bind(&net_plugin_impl::transaction_ack, my.get(), _1)); if( cc.get_read_mode() == chain::db_read_mode::READ_ONLY ) { @@ -3090,7 +3091,12 @@ namespace eosio { for( auto seed_node : my->supplied_peers ) { connect( seed_node ); } - handle_sighup(); + + } catch (...) { + // always want plugin_shutdown even on exception + plugin_shutdown(); + throw; + } } void net_plugin::handle_sighup() { diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 4291dffaeb6..a9cfab68cb4 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -804,6 +804,7 @@ void producer_plugin::plugin_startup() { try { handle_sighup(); // Sets loggers + try { ilog("producer plugin: plugin_startup() begin"); chain::controller& chain = my->chain_plug->chain(); @@ -840,6 +841,11 @@ void producer_plugin::plugin_startup() my->schedule_production_loop(); ilog("producer plugin: plugin_startup() end"); + } catch( ... ) { + // always call plugin_shutdown, even on exception + plugin_shutdown(); + throw; + } } FC_CAPTURE_AND_RETHROW() } void producer_plugin::plugin_shutdown() {