Skip to content

Commit

Permalink
bringing over changes from the dawn 2.x branch to ensure no pending f…
Browse files Browse the repository at this point in the history
…ixes are lost.
  • Loading branch information
pmesnier committed Jan 25, 2018
1 parent 7a0d099 commit eb5a605
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,10 @@ namespace eosio {
}

void connection::send_handshake( ) {
handshake_message hello;
handshake_initializer::populate(hello);
hello.generation = ++sent_handshake_count;
last_handshake_sent = hello;
handshake_initializer::populate(last_handshake_sent);
last_handshake_sent.generation = ++sent_handshake_count;
fc_dlog(logger, "Sending handshake to ${ep}", ("ep", peer_addr));
enqueue(hello);
enqueue(last_handshake_sent);
}

char* connection::convert_tstamp(const tstamp& t)
Expand Down Expand Up @@ -857,21 +855,33 @@ namespace eosio {
conn->write_depth--;

if(ec) {
elog("Error sending to connection: ${i}", ("i", ec.message()));
string pname = conn ? conn->peer_name() : "no connection name";
if( ec.value() != boost::asio::error::eof) {
elog("Error sending to peer ${p}: ${i}", ("p",pname)("i", ec.message()));
}
else {
ilog("connection closure detected on write to ${p}",("p",pname));
}
my_impl->close(conn);
return;
}
conn->write_queue.pop_front();
conn->do_queue_write();
}
catch(const std::exception &ex) {
elog("Exception in do_queue_write ${s}", ("s",ex.what()));
auto conn = c.lock();
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in do_queue_write to ${p} ${s}", ("p",pname)("s",ex.what()));
}
catch(const fc::exception &ex) {
elog("Exception in do_queue_write ${s}", ("s",ex.to_string()));
auto conn = c.lock();
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in do_queue_write to ${p} ${s}", ("p",pname)("s",ex.to_string()));
}
catch(...) {
elog("Exception in do_queue_write");
auto conn = c.lock();
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in do_queue_write to ${p}", ("p",pname) );
}
});
}
Expand Down Expand Up @@ -1409,26 +1419,35 @@ namespace eosio {
}
start_read_message(conn);
} else {
elog( "Error reading message from connection: ${m}",( "m", ec.message() ) );
auto pname = conn->peer_name();
if (ec.value() != boost::asio::error::eof) {
elog( "Error reading message from ${p}: ${m}",("p",pname)( "m", ec.message() ) );
} else {
ilog( "Peer ${p} closed connection",("p",pname) );
}
close( conn );
}
}
catch(const std::exception &ex) {
elog("Exception in handling read data ${s}", ("s",ex.what()));
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in handling read data from ${p} ${s}",("p",pname)("s",ex.what()));
close( conn );
}
catch(const fc::exception &ex) {
elog("Exception in handling read data ${s}", ("s",ex.to_string()));
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in handling read data ${s}", ("p",pname)("s",ex.to_string()));
close( conn );
}
catch (...) {
elog( "Undefined exception hanlding the read data from connection: ${m}",( "m", ec.message() ) );
string pname = conn ? conn->peer_name() : "no connection name";
elog( "Undefined exception hanlding the read data from connection ${p}",( "p",pname));
close( conn );
}
}
);
} catch (...) {
elog( "Undefined exception handling reading" );
string pname = conn ? conn->peer_name() : "no connection name";
elog( "Undefined exception handling reading ${p}",("p",pname) );
close( conn );
}
}
Expand Down Expand Up @@ -1620,6 +1639,7 @@ namespace eosio {

void net_plugin_impl::handle_message( connection_ptr c, const go_away_message &msg ) {
string rsn = reason_str( msg.reason );
ilog( "received a go away message, reason = ${r}",("r",rsn));
c->no_retry = msg.reason;
if(msg.reason == go_away_reason::duplicate ) {
c->node_id = msg.node_id;
Expand Down Expand Up @@ -2300,7 +2320,7 @@ namespace eosio {
// If we couldn't sign, don't send a token.
if(hello.sig == chain::signature_type())
hello.token = sha256();
hello.p2p_address = my_impl->p2p_address;
hello.p2p_address = my_impl->p2p_address + " - " + hello.node_id.str().substr(0,7);
#if defined( __APPLE__ )
hello.os = "osx";
#elif defined( __linux__ )
Expand Down

0 comments on commit eb5a605

Please sign in to comment.