diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 3c8ab0b5bfc..fd9cdaba78d 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -577,7 +577,7 @@ namespace eosio { fc::sha256 node_id; const uint32_t connection_id; int16_t sent_handshake_count = 0; - std::atomic connecting{false}; + std::atomic connecting{true}; std::atomic syncing{false}; uint16_t protocol_version = 0; uint16_t consecutive_rejected_blocks = 0; @@ -914,7 +914,6 @@ namespace eosio { socket.set_option( nodelay, ec ); if( ec ) { fc_elog( logger, "connection failed to ${peer}: ${error}", ("peer", peer_name())( "error", ec.message() ) ); - connecting = false; close(); return false; } else { @@ -2146,7 +2145,6 @@ namespace eosio { } ); } else { fc_elog( logger, "connection failed to ${peer}: ${error}", ("peer", c->peer_name())( "error", err.message())); - c->connecting = false; c->close( false ); } } @@ -2155,6 +2153,7 @@ namespace eosio { void net_plugin_impl::start_listen_loop() { connection_ptr new_connection = std::make_shared(); + new_connection->connecting = true; acceptor->async_accept( new_connection->socket, boost::asio::bind_executor( new_connection->strand, [new_connection, this]( boost::system::error_code ec ) { if( !ec ) { @@ -2462,9 +2461,7 @@ namespace eosio { ("g", msg.generation)( "ep", peer_name() ) ( "lib", msg.last_irreversible_block_num )( "head", msg.head_num ) ); - if( connecting ) { - connecting = false; - } + connecting = false; if (msg.generation == 1) { if( msg.node_id == node_id) { fc_elog( logger, "Self connection detected node_id ${id}. Closing connection", ("id", node_id) );