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

connection via listen needs to start in connecting mode #7537

Merged
merged 4 commits into from
Jun 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ namespace eosio {
fc::sha256 node_id;
const uint32_t connection_id;
int16_t sent_handshake_count = 0;
std::atomic<bool> connecting{false};
std::atomic<bool> connecting{true};
std::atomic<bool> syncing{false};
uint16_t protocol_version = 0;
uint16_t consecutive_rejected_blocks = 0;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 );
}
}
Expand All @@ -2155,6 +2153,7 @@ namespace eosio {

void net_plugin_impl::start_listen_loop() {
connection_ptr new_connection = std::make_shared<connection>();
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 ) {
Expand Down Expand Up @@ -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) );
Expand Down